JasperReports is an open source Java reporting tool, it can be used in Java-enabled applications, including Java EE or web applications, to generate dynamic reports/content into several output types including PDF, HTML, CSV, and XLS. Reports are defined in an XML file format, called JRXML, which can be hand-coded, generated, or designed using iReport engine or any IDE with iReport plugin installed.

iReport is the free, open source report designer for JasperReports. It creates layouts containing charts, images, subreports, crosstabs and much more. Access your data through JDBC, TableModels, JavaBeans, XML, Hibernate, CSV, and custom sources. Then publish your reports as PDF, RTF, XML, XLS, CSV, HTML, XHTML, text, DOCX, or OpenOffice.

JRXML is an XML defined by a Document Type Definition (DTD) or XML schema, it contains the report template, it can be written by hand too, but for most complex reports we must design using the iReport. A .jasper is a compiled XML file by iReport. The main difference between using JRXML and a .jasper file is that the JRXML file should be compiled at runtime using the JasperCompileManager class.

Report Template contains the following sections:

  1. Title
  2. Page Header
  3. Column Header
  4. Detail
  5. Column Footer
  6. Page Footer
  7. Summary
  8. Background

Title contains the title of the report. It displays only once at the very beginning of the report, Ex: Company image or Company Tile.

Page Header:
This appears at top of each page. Ex: Bank report contains Account number, name etc.

Column Header:
This lists the names of specific fields which you want to display in the report. Ex: Name, Address, Phone Number, etc.

Detail is the part where actual entries (data) come from database or any other resources.

Column Footer:
This may contain the total or note of the report. Ex: Total Amount: 1200 etc.

Page Footer:
This may contain page count information and Date/Time. It appears at the bottom of each page.

This is the last section which displays at end of the report, it can contains the statistical information, you can display charts or summary of the report.

This is used to display the background copyright or watermarks.

JasperReport Features:

  • It is an open source java enabled, it has flexible report layout.
  • It can accept data from multiple datasources.
  • It can transform into several output types including PDF, HTML, CSV, and XLS.
  • It can generate reports into textually or graphically.

We need the following files to run the JasperReports and copy these jars over to your/WEB-INF/lib directory, and add them to your classpath:

  • dist/jasperreports-X.jar
  • lib/commons-*.jar (all the commons)
  • lib/itext-X.jar
  • lib/jdt-compiler.jar

Download library from http://www.sourceforge.net/projects/jasperreports