A Short Intorduction to JasperReports


Published on

Published in: Technology, Education
  • Be the first to comment

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

No notes for slide

A Short Intorduction to JasperReports

  1. 1. 1Albert Guo
  2. 2. 2Agenda Introduction Prerequisites Typical Workflow Document Sections (Bands) Overview JasperReports Architecture
  3. 3. 3Introduction Open source Java reporting library Under the Lesser GNU Public License (LGPL) Since 2001 Backed by a company now, JasperSoft 2007 Duke’s Choice Award Winner
  4. 4. 4Introduction – cont. Support multiple data sources  Database connection  Embedded SQL statement  Java Collections (Collection, Array and Map)  JDBC result set Support multiple report formats  PDF, XLS, CSV, HTML, XML, RTF, ODT, TXT
  5. 5. 5Prerequisites Download Sun Java 2 SDK 1.5 or newer iReport eats a lot of RAM, and so it is necessary to have at least 256MB of memory and about 20MB of free space on disk Download iReport from http://sourceforge.net/projects/ireport Download JasperReports from http://sourceforge.net/projects/jasperreports/files/jasperreport s/
  6. 6. 6Fail to open jrxml by iReport Problem  As I use iReport 4.0.2 to open jrxml file, but it show this error message:  javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.j ava:134) at org.netbeans.lib.uihandler.LogRecords.scan(LogRecords.java:127) at org.netbeans.modules.uihandler.Installer.getLogs(Installer.java:681) at org.netbeans.modules.uihandler.Installer$Submit.(Installer.java:1317) Solution  Change your JAVA_HOME to standard JDK instead of IBM JDK.
  7. 7. 7Typical Workflow
  8. 8. 8Document Sections (Bands)Overview
  9. 9. 9 Document Sections (Bands) OverviewDocument DescriptionSectionstitle printed only once at the beginning of the reportpageHeader printed at the beginning of every page in the report.Column Header printed at the beginning of each detail columnDetail corresponds to every record that is read by the datasource that feeds the reportColumn Footer The column footer band appears at the end of every column.Page Footer The page footer band appears on every page where there is a page headerSummary The summary band allows you to insert fields concerning total calculations, means, or whatever you want to insert at the end of the report
  10. 10. 10Check “Blank When Null”
  11. 11. 11Avoid broken character
  12. 12. 12JasperReports Architecture
  13. 13. 13JasperReports Architecture
  14. 14. 14 http://0rz.com/RMSbdYMaven 2 JasperReports Plugin This plugin provides the capability to compile Jasper Report xml design files.
  15. 15. 15JasperReports Architecture
  16. 16. 165 Steps to export reportStep DescriptionGet data source Input List of value object, and create JRBeanCollectionDataSourceRead Jasper Read .jasper fileFileGenerate Read report input stream and create JasperPrintJasperPrint objectSet response Assign content type and header based on thecontent type and export typeheaderExport Report Assign export API to do export based on the export type
  17. 17. 17 http://0rz.com/3MrvkI5 Steps to export report – cont.
  18. 18. 18MS Excel wasnt displaying a CSVfile with UTF-8 encoding correctly.
  19. 19. 19MS Excel wasnt displaying a CSVfile with UTF-8 encoding correctly. In the absence of any charset identification, Excel must guess about a files content encoding. Therefore, Excel uses that default to read and display CSV files. //byte-order marker (BOM) byte b[] = {(byte)0xEF, (byte)0xBB, (byte)0xBF}; //insert BOM byte array into outputStream outputStream.write(b); http://http://0rz.com/QFcaEW