Reporting in Java

Only available on StudyMode
  • Topic: Bar chart, Chart, Pie chart
  • Pages : 11 (2672 words )
  • Download(s) : 102
  • Published : January 27, 2013
Open Document
Text Preview
A Tutorial on JasperReports, iReport and JFreeChart

Página 1 de 21

A Tutorial on Reporting in JAVA using JasperReports, iReport and JFreeChart Onur Derin, oderin(a)softhome.net, Parsera Information Technologies This tutorial aims to get the reader acquianted with the three of the open source JAVA reporting tools, namely JasperReports[1], iReport[2] and JFreeChart[3]. A.What is a Report? B.How are JasperReports, iReport and JFreeChart related? JasperReports iReport JFreeChart C.Creating a Sample Report with JasperReports, iReport and JFreeChart Creating the XML File for JasperReports using iReport Creating the Final Report using JasperReports Creating Report Images using JFreeChart Pie Chart Bar Chart Hints Referrences Useful Links Appendix A Sample JasperReport XML File – sample.jrxml Appendix B Sample JasperReports JAVA File - sample.java

A. What is a Report?
A report is a nicely formatted way of presenting the data that you have entered. Reports are all about querying a database and displaying the results in a nice format. Data in the database may be displayed just as is, that is, in hundreds of pages. However, most of the time, reports are used to grasp information out of a bunch of data. This is mainly done by charts which are graphical representations of information. When the data is processed to fill out a report, calculations are done over the specific fields of the entries. The results appear as bars or pies in a chart or as text at the end of the report. Many of the commercially available reporting tools have the following layout for a report page.

http://members.lycos.co.uk/oderin/tutorials/JavaReporting/JavaReportingTutorial.htm?

03/01/2005

A Tutorial on JasperReports, iReport and JFreeChart

Página 2 de 21

Figure 1: General Report Template title appears only once at the very beginning of the report. Title of the report is written in this part. eg. “Employee Performance Report” pageHeader appears at the top of each page. This part may contain date and time information and/or organization name. columnHeader lists names of those specific fields which you want to display. eg. “Employee Name”, “Starting Hour”, “Finishing Hour”, “Hours Worked”, “Date” detail is the part where those fields of the entries are shown. eg. “John Doe”, “09:00”, “18:00”, “9”, “16.07.2004” columnFooter may display summation of any of the fields. eg. “Total Hours Worked: 180” pageFooter appears at the bottom of each page. This part may contain page count information like “1/7”. summary is the part where information inferred from the data in the “detail” part is displayed. For example, after listing the worked hours for each employee in “detail” part, total hours worked for each employee can be put in a pie to enable a better visual comparison between the employees.

  B. How are JasperReports, iReport and JFreeChart related?   JasperReports
JasperReports is an engine that takes an XML file and forms a report out of that file using the data source specified in the XML file. A sample XML file is given in Appendix A. This file defines exactly what appears where in the report. Writing this file by hand is not practical. This is where

http://members.lycos.co.uk/oderin/tutorials/JavaReporting/JavaReportingTutorial.htm?

03/01/2005

A Tutorial on JasperReports, iReport and JFreeChart

Página 3 de 21

iReport comes into play. For more information on JasperReports, see http://jasperreports.sourceforge.net/tutorial/index.html

iReport
iReport is a visual tool to obtain XML files for JasperReports. It provides a WYSIWYG environment to design reports. Sample.jrxml in Appendix A is obtained using iReport. Anything that can be placed in a report (static text, geometric shapes, images, subreports, groups, texts and images coming from a data source)can be put together in drag’n’drop fashion according to the report template shown in Figure 1.

   

For more information on JasperReports, see...
tracking img