Japer Reports


Published on

This presentation gives Introduction to Jasper Reports.

  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Japer Reports

  1. 1. Jasper Reports
  2. 2. Introduction An open-source Java class library. Designed to aid developers with the task of adding reporting capabilities to Java Application. Provide an ability to facilitate the ability to generate reports from any kind of Java Application. It is embedded into Java applications by including its library in the application's CLASSPATH.
  3. 3. Features It has flexible report layout. It is capable of presenting data textually or graphically. It allows developers to supply data in multiple ways (e.g. Parameters, datasources). It can accept data from multiple datasources (e.g. XML, POJO's, java.util.Map). It can generate Subreports. It can generate watermarks. It can capable of exporting reports to a variety of formats (e.g. pdf, HTML, excel).
  4. 4. Typical Workflow Create JRXML Compile JRXML into Jasper template Fill the Jasper template to generate the report Export No Report? Yes Export the Report Report is printed or displayed on screen
  5. 5. Downloading Jasper Reports Download latest jasper reports jar file from http://sourceforge.net/projects/jasperreports Following are Jasper Report dependencies: Dependency Comments Commons Logging Used for sending output to log Commons Collections Used to manage collections of data Commons BeanUtils User for Java Beans Introspection Commons Digester Used for XML parsing JFreeChart Only requires when the report contains chart iText Only requires when exporting reports to PDF or RTF Hibernate Only required when writing report using the Hibernate Query Language (HQL)
  6. 6. Reports Section
  7. 7. title: It is created only once and can be printed on a separate page. pageHeader: The page header appears on all printed pages in the same position defined during the design phase. columnHeader: This band is printed at the beginning of each detail column. detail: A detail band corresponds to every record that is read by datasource that feeds the report. background: This element is used to define the page background for all pages in the report. It can be used to display images or text and also to display watermarks.
  8. 8. columnFooter: This band appears at the end of every column. Not resizable at run time. pageFooter: This band appears on every page where there is a page header. lastPageFooter: If you want to make the last page footer different then it is possible to use the special las page footer band. summary: This band allows you to insert fields concerning total calculations, means, or whatever you want to insert at the end of the report.
  9. 9. JRXML file <?xml version="1.0" encoding="UTF-8"?> <detail> <!DOCTYPE jasperReport PUBLIC <band height="100"> "//JasperReports//DTD Report Design//EN" </band> "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> </detail> <columnFooter> <jasperReport name="simple_template"> <band height="30"> <title> </band> <band height="50"> </columnFooter> </band> <pageFooter> </title> <band height="50"> <pageHeader> </band> <band height="50"> </pageFooter> </band> <lastPageFooter> </pageHeader> <band height="50"> <columnHeader> </band> <band height="30"> </lastPageFooter> </band> <summary> </columnHeader> <band height="50"> </band> </summary> </jasperReport>
  10. 10. Elements in JRXML <staticText> : Defines static text that does not depend on any datasources, variables, parameters, or report expressions. <textField>: Used to display dynamic textual data in reports. <textFieldExpression>: Defines the data that is displayed in text fields. <field>: This element is used to map data from datasources or queries into report templates. Fields can be combined in report expressions to obtain the necessary output. A JRXML template can contain zero or more <field> elements.
  11. 11. <variable>: Report expressions, used several times in a report, can be assigned to variables to simplify the template. A JRXML template can contain zero or more <variable> elements. <parameter>: This element is used to define report parameters. Parameter values are supplied via a java.util.Map by calling the appropriate methods in the JasperReports API. A JRXML template can contain zero or more <parameter> elements. <group>: This element is used to group consecutive records in a datasource sharing some common characteristics. A JRXML template can contain zero or more <group> elements.