Jump to content
Changes to the Jaspersoft community edition download ×
  • Basic Report Creation


    Guest

    iReport/Jaspersoft Studio Support Announcement
    As of version 5.5.0, Jaspersoft Studio will be the official design client for JasperReports. iReport will remain as a supported product in maintenance-only mode until December 31, 2015, meaning we will continue to fix critical defects in upcoming releases but no new features will be added to the iReport client. Continue to maintain your existing reports with the new Jaspersoft Studio!

    This guide helps you to create your first report. It uses FoodMart data source, a MySQL database example provided when installing JasperReports Server.

    Let's start

    1. Launch iReport. Click on File > Empty report.

      Basic_Report_Creation_1.JPG.ff96fa08b36e80c35775566edfe489e9.JPG

    [toc]
    1. Name your report and choose a path to store it.

      Basic_Report_Creation_2.JPG.ecad7ad05c8f8a88a57d2a5d804e4fd8.JPG

    2. Do Finish.

      Basic_Report_Creation_3.JPG.e542fed3c66b7f95d767213740bf9640.JPG

    Define Data Source

    1. Define FoodMart as your data source. See iReport - Adding a Data Source for a guide.

      Basic_Report_Creation_4.JPG.8df651036380f33fa8dfb8cc4bcb2b0b.JPG

    Report Query

    1. Click on Edit Report Query icon.

      Basic_Report_Creation_5.JPG.f09064c1b3ab5b38b491029da6ea0261.JPG

    2. Copy and paste the below SQL query in the Edit Report Query window.

      SELECT emp.employee_id, emp.first_name, emp.last_name, emp.position_title, emp.birth_date,
      emp.hire_date, emp.end_date, emp.salary, emp.gender, dep.department_id, dep.department_description
      FROM employee emp
      JOIN department dep ON (emp.department_id=dep.department_id)
      WHERE dep.department_id IN (1,2,3,4,5);
      

      Basic_Report_Creation_6.JPG.a384d3fac6d29bb7f13a5c191a5ee611.JPG

      Note: if your query is valid, iReport will automatically retrieve the fields. If not, check your query mistakes.

    3. Then do OK to save your SQL query. You will see on your left the Report Inspector panel filled with query's fields.

      Basic_Report_Creation_7.JPG.f4db0af14b440acd85d494e125d67a1e.JPG

    4. For this example, keep the following bands: Page Header, Detail and Page Footer.
    5. To delete bands, right click on it and select Delete Band.

      Basic_Report_Creation_8.JPG.0b9c69aa878a03b1f1b1d95d6cb12cbf.JPG

    Let's fill it out

    Page Header Band

    Palette Window

    The Palette window contains different types of elements for a report.

    1. To activate Palette, click on Window > Palette.

      Basic_Report_Creation_9.JPG.b23c70bc23658df45c53818b47795f5d.JPG

    2. Drag and drop 6 Static Text fields in Page Header band. Double click on each one and name them as below:

      Basic_Report_Creation_10.JPG.9cef4374a5e54d820a16514858e81a65.JPG

    Properties Window

    Properties allow you to customize elements of a report.

    1. To activate Properties, click on Window > Properties.
    2. Select any static field and modify its properties: backcolor, text size, bold, italic, field size...

      Basic_Report_Creation_11.JPG.56411394177de3b75dd8aeb4ac995c00.JPG

      Note: some properties are directly available on that mini toolbar

      Basic_Report_Creation_12.JPG.de3907b5e961555459339b05d9a9fa98.JPG

    3. Select all static fields, right-click and select Padding and Borders. Modify the Line witdh value to 1 and Line color to black. Then do OK.

      Basic_Report_Creation_13.JPG.66004f070351fc2654d779856a4e61fa.JPG

    Formatting Tools Window

    This is really important to use these tools. You can save a lot of time when creating reports !

    1. To activate Formatting Tools, click on Window > Formatting Tools.
    2. Select the following static fields: First Name, Last Name, Position Title, Salary, Department. In the Formatting Toolswindow, click on Align Top and Remove Horiz. Space.

      Basic_Report_Creation_14.JPG.934908b916dea6749f8fea6ac147b781.JPG

      See the difference, your fields are well organize with only 2 clicks.

      Basic_Report_Creation_15.JPG.68299ec8bd82727e7012150127640dcd.JPG

    3. Double click on the bottom border of Page Header band to reduce its height.

      Basic_Report_Creation_16.JPG.9c78b0fa87762ed695b9f3f9489047db.JPG

      Now you know basic tools to create contents for your report.



    Detail Band

    1. Drag from Report Inspector and drop in Detail band the following fields:

      first_name, last_name, position_title, salary, department_description.

    2. Double click on the bottom border of Detail band to reduce its height.

      Basic_Report_Creation_17.JPG.32769c3a39f2e913b71e84b9a26d638d.JPG

    Page Footer Band

    1. Drag from Palette and drop in Page Footer band the 2 elements Current Date and Page X of Y.

      Basic_Report_Creation_18.JPG.791f63ae99529559248769634260480a.JPG

    2. For Current Date element, choose an appropriate pattern.

      Basic_Report_Creation_19.JPG.b271bf40d71f62796593cda03e276745.JPG

    3. Place the 2 elements. Don't forget to stretch enough Current Date element to display the entire date. Double click on the bottom border of Page Footer band to reduce its height.

      Basic_Report_Creation_20.JPG.0b55a67af9ed85da23ae2a252a2150e7.JPG

    Report Preview

    1. To preview your report, click on Preview button.

      Basic_Report_Creation_21.JPG.d11896de160a2e9316f5f30282ecb4bb.JPG

    2. See the preview. Not bad but they are some issues:

      • Text touches cells' borders.
      • Salary display pattern is not clear.
      • Some department's descriptions are truncated

        Basic_Report_Creation_22.JPG.66c74793d2af1a69d0c05af08fceab31.JPG

    Improving Display

    1. '''Text touches cells' borders:''' add some padding for all Detail band's elements: 5px for Left and Right; 2px for Top and Bottom.

      Basic_Report_Creation_23.JPG.5b5f0d687663a1cacaee1289615e2875.JPG

    2. Salary display pattern: see Salary field's Properties. Add the following Pattern:

      $ ###,###,##0.00
      

      Basic_Report_Creation_24.JPG.b5c6d8ea2e6fe4b3bc8bf97ce7aac214.JPG

    3. Truncated column: select all Detail band's elements and go to Properties. Set Stretch Type to Relative to Band Height. Check Stretch With Overflow box.

      Basic_Report_Creation_25.JPG.8d5c7db72c75c4b6cf92eb451db22355.JPG

    4. Click on Detail band and go to Properties. Uncheck Split allowed box. This will prevent from row splitting between 2 pages.

      Basic_Report_Creation_26.JPG.b700b947521f04a00038c4b5201c94d2.JPG

    5. See the preview. Your report looks better now.

      Basic_Report_Creation_27.JPG.9f1827a545423cc86cd05b3df01d3c5d.JPG

    See also...


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...