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 | [toc] |
Define Data Source
Define FoodMart as your data source. See iReport - Adding a Data Source for a guide.
Report Query
Click on Edit Report Query icon.
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);
Note: if your query is valid, iReport will automatically retrieve the fields. If not, check your query mistakes.
Then do OK to save your SQL query. You will see on your left the Report Inspector panel filled with query's fields.
- For this example, keep the following bands: Page Header, Detail and Page Footer.
To delete bands, right click on it and select Delete Band.
Let's fill it out
Page Header Band
Palette Window
The Palette window contains different types of elements for a report.
To activate Palette, click on Window > Palette.
Drag and drop 6 Static Text fields in Page Header band. Double click on each one and name them as below:
Properties Window
Properties allow you to customize elements of a report.
- To activate Properties, click on Window > Properties.
Select any static field and modify its properties: backcolor, text size, bold, italic, field size...
Note: some properties are directly available on that mini toolbar
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.
Formatting Tools Window
This is really important to use these tools. You can save a lot of time when creating reports !
- To activate Formatting Tools, click on Window > Formatting Tools.
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.
See the difference, your fields are well organize with only 2 clicks.
Double click on the bottom border of Page Header band to reduce its height.
Now you know basic tools to create contents for your report.
Detail Band
Drag from Report Inspector and drop in Detail band the following fields:
first_name, last_name, position_title, salary, department_description.
Double click on the bottom border of Detail band to reduce its height.
Page Footer Band
Drag from Palette and drop in Page Footer band the 2 elements Current Date and Page X of Y.
For Current Date element, choose an appropriate pattern.
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.
Report Preview
To preview your report, click on Preview button.
See the preview. Not bad but they are some issues:
Improving Display
'''Text touches cells' borders:''' add some padding for all Detail band's elements: 5px for Left and Right; 2px for Top and Bottom.
Salary display pattern: see Salary field's Properties. Add the following Pattern:
$ ###,###,##0.00
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.
Click on Detail band and go to Properties. Uncheck Split allowed box. This will prevent from row splitting between 2 pages.
See the preview. Your report looks better now.
Recommended Comments
There are no comments to display.