Jasper Report is an open source java reporting engine, is Java based and doesn’t have its own expression syntax.

As JasperReports is a Java class library, and is not meant for end users, but rather is targeted towards Java developers , hence we use IReport for users who need to add reporting capabilities to their applications.


Report Definition file structure (jrxml):-

Jasper design file –jrxml- contains the following elements:
<jasperReport>: the root element.
<title>: its contents are printed only once at the beginning of the report
<pageHeader> – its contents are printed at the beginning of every page in the report.
<detail> – contains the body of the report, repeated by n number of results
<pageFooter> – its contents are printed at the bottom of every page in the report.
<band> – defines a report section, all of the above elements contain a band element as its only child element.


Only the root element is mandatory, the rest of elements are optional.

JasperReport works in a way similar to a compiler and an interpreter. See fig. 3.1. The user design a report coding it in XML in agreement to tags and attributes defined in a file called jasperreports.dtd (part of JasperReports). Using XML a user define the entire report, describing where place texts, images, lines, rectangles, how to retrive data, how to make certain calculations to show subtotals, etc…



Fig.3.1: How JasperReports works.

This XML source file must be compiled in order to produce a real report. The compiled version of the source is named “jasper file” (it ends with .jasper). A jasper file is a compiled report source.
When we have a jasper file, we need another thing in order to produce a report: we need data. This is not always true. In some cases We could want to generate a report that don’t shows dynamic data, but i.e. only static text, but this can be reduced to a report that has only an empty record. To supply this records to the jasper engine we need to present it using a special jasperreports specific interface named JRDataSource. A datasource + a jasper file = a print. A print can then be exported in many formats like PDF, HTML, XML, XLS, CVS, etc… The export will be done using special classes the implement specific exporters. 


3.2 Compilation end export of reports
For a newbie, design and create the jasper file is the hardest work. When you have designed and compiled your jasper file, you can use the JasperReport library to dinamycally fill your report in several enviroments like a web application (using i.e. java servlet, but I have succesfully used JasperReports for generating PDF reports calling it from a PHP script…).
Jasper make available a special viewer to display a report preview, designed for swing based traditional java applications.


Fig.3.2: JasperReports can easily integrated in a Web application as in a java swing based program.

3.3 Our first very simple report
iReport provide to jasper reports users a visual interface to build reports, generate jasper files and test prints. iReport born as development tool, but it can be used as an office tool to retrieve and print data stored in a database, without pass through another application.


Fig.3.3: How JasperReports works.

iReport can read and modify both jasper XML and jasper files. Trought jasperreports, it’s able to compile XML to jasper files and “run reports” to fill it using several types of JRDataSource and export the result to PDF,HTML,XLS,CSV,…


Points to Note in Different Types of Jasper Reports :-

  1. All fields need to be inside the band in which it is defined such that no field or label is observed with a red triangle on it. In such case report will not get compiled.
  2. Do take care of the band in Jasper Report such that Page Footer repeats on every Page while summary comes only on the end of  the report.
  3.  SQL Queries used in the IReport must be first tested on the SQL Server edition or any 3rd party Application and query shouldn’t be straight forward feeded to report.
  4. SQL Query copied in IReport should be free of Commented Code and semicolons as these will lead to non compilation of query.
  5. Just enter the column name in System Element and press Enter, the System will automatically correct the case of the name and copy this name to your report parameter.
  6. Do not give spaces in Report Name or in Parameters, as this will lead to Process Error null, or Could not find Report Error at runtime.
  7. While using Parameters in SQL in IReport, make sure while using like operator , insert “!” in the Parameter before the name.
  8. While working with subreports, provide a path which is dynamic such that when u change the location of the report the subreport doesn’t stops functioning

-Try Providing the path of WAR file such that , when u need to change u just need to change the Address of Server in the same format as defined in Report and Process

If the need of ever hiding the Parameters Arises, i.e. hardcoding them from the front, u can follow the changes and the parameter wont be displayed on running of report.


  • Make the name of Parameter Blank by Just inserting a space in the name or Add the name and use Display logic
  • In the Display Logic Field, add a check of the Parameter which can not be null like Organization which will hide the field too.
  • Organization or any parameter will be used with ‘=’ sign in Display Logic and ‘is null wont work in Enterprise version’.
  • Using the current modification we can segregate many reports into one and just place a single jrxml file in the WAR and create multiple menus or even a single menu and use list parameter in it.


    • The crosstab must be placed in Summary Only as then only the report will Compile, Placing the Report in any other band will lead to error.
    • In case of report while getting Sub Totals and Grand Totals , just add the variable in the crosstab and change the Calculation Type to  ‘ Sum ’
    • While Creating Crosstab if all the variables are not added, we need to add them later once the crosstab is created by adding them in measures section.
    • Once added in Measures Section we just need to drag and drop the fields in the report such that it automatically gets arranged.




                                                                                                                                                                                                       -By Adempiere Support {India Portal}

About This Author

Post A Reply