Jasper Reports Basics
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:
- Page Header
- Column Header
- Column Footer
- Page Footer
Title contains the title of the report. It displays only once at the very beginning of the report, Ex: Company image or Company Tile.
This appears at top of each page. Ex: Bank report contains Account number, name etc.
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.
This may contain the total or note of the report. Ex: Total Amount: 1200 etc.
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.
- 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:
- lib/commons-*.jar (all the commons)
Download library from http://www.sourceforge.net/projects/jasperreports