This blog talks about the best practices which should be followed when creating reports using iReport or Jasper studio, deploying the same on Jaspersoft server, nomenclature to be used etc.
1) Report Margins:
When you develop reports for dashboards, it is advisable to keep all the margins with 0 pixels.
By default margins will be
Left margin 20
Right margin 20
Top margin 20
Bottom margin 20
Change the values to 0
Left margin 0
Right margin 0
Top margin 0
Bottom margin 0
Because, when set to 0 report panels are well fit when designing the dashboards.
2) Bands to keep the components
Do not keep table component, cross tab component in Detail band. Keep all the components either in Title band or in Summary Band as per the requirement. It is advisable to create custom bands to keep the different charts if you need to develop a report with multiple charts.
Why it is not recommended to keep the components in Detail band?
Details band falls into loop till the end of the row/data for fields hence if you keep any other component it will fall in a loop and will give you unexpected behaviour of iReport with bad output.
3) Parameter Naming conventions
It is advisable to give good naming conventions for parameters. For example parameter name could be param_paramName or p_paramName
Eg : 1) p_startDate 2) p_endDate
Other Naming conventions
The same thing you can apply when you create input controls /Data source Names/Custom band names/Data Set names in iReport & Jasper Repository respectively.
Easy to differentiate the variables, parameters and group names etc
4) Remove the other bands which you are not going to use in iReports
5) Variables and Parameter usage in iReport
Make use of internal parameters for the report and for the summation of columns recommended to use the variables.
6) Jasper Project Folder Structure
archive (take a back up of jrxmls if you are going to update/modify them in this folder with a version number)
Input Controls ( All your parameter names for the project/various reports)
Data sources(This folder is useful when you have multiple databases to use in your project)
Files(Keep all your data source files here, for eg : Excel, CSV, XML and etc)
JRXML’s (Whatever the JRXMLS you are creating you can keep all of them in this folder)
Sub Reports(keep all you sub reports in this folder and refer from here where ever you want)
Images(Keep all your images in this folder- for easy understanding)
Reports(Keep all your reports in this folder)
Dashboards(Save all your dashboards here)
Temp (for temporary files)
Test (Do experiment at the time of development of report in this folder)
Note that if your project is having lot many reports according to some sections/departments, it is advisable to sub divide the Reports folder with other folders.
When you upload a report to JRXML it is recommended to write the description of the report. By seeing it every one can easily understand the purpose of the report/visualization.
7) Export / Import Utility
Command line utility to import/export/update folders/reports from the jasper server is given below.
js-import –input-zip(space) <Filename>
Ex: js-import –input-zip(space)”E:Work Space\Unified\Unified Reports\<file name>”
js-import –input-zip(space)”E:Work Space\Unified\Unified Reports\<file name>” –update
js-export <location of the folder in jasper server> –output-zip <location of exporting folder>/<exporting_filename.zip>
· Every report must have some name, give the name of the report in this band.
· Blue colour back ground with white colour font is preferable to give the titles.
· Logos of the company are recommended to be placed left side of the band in title band under the title of the report.
· Page header consists of the page numbers and date type of information. It is recommended to give page header information for long reports with heavy text involved in the reports.
· This band is used for giving column headers for the fields. You can change the font style, size, give the borders, back ground colours and etc.
· Detail band is used to display the output of the report using fields fetched by the query.
· You need to drag and drop required fields to create the report to Detail band format them accordingly.
· Detail band falls into for loop so we should keep only fields in this band rather than keeping any other component like table , cross tab, chart components.
· This band is used to find the total, max, min of the columns from the details band.
· You need to create variable for this and drag that variables under the column where you want see the sum, max or min
· Page footer is used to place the page numbers, confidential type of text for the company etc.
· Summary of the report will be placed in the summary band.
· Generally we keep the chart component, table component, cross tab component to summarize the report.
9) 9) Why should we keep input controls and data sources in resource folder?
Input controls in repository:
Create all your input controls in resource folder because every time for each report you need not to create the same input controls. You just need to link the existing input control from the repository folder.
Data sources in repository:
It is considered as a best practice to create data source connections in a folder called resources and use this data source for the reports. It’ll reduce the report development time. You need to not create import database connections from iReport once you create this connection in the repository.