Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
29Activity
0 of .
Results for:
No results containing your search query
P. 1
JasperReports Tutorial

JasperReports Tutorial

Ratings: (0)|Views: 3,399|Likes:
Published by api-26853881

More info:

Published by: api-26853881 on Dec 03, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

03/18/2014

pdf

text

original

 
 JB’s Collection
Page No
1 of 18
JasperReports Tutorial
JasperReports Tutorial - Introduction
JasperReports is a powerful open source reporting tool that has the ability to deliver richcontent onto the screen, to the printer, or into PDF, HTML, XLS, CSV and XML files. It isentirely written in Java and can be used in a variety of Java-enabled applications to generatedynamic content. Its main purpose is to help create page-oriented, ready-to-print documentsin a simple and flexible manner.JasperReports organizes data retrieved from a relational database through JDBC according toa report-design defined in an XML file. In order to fill a report with data, the report-designmust be compiled first.The compilation of the XML file representing the report-design is performed by thecompileReport() method exposed by the net.sf.jasperreports.engine.JasperManager class.Through compilation, the report design is loaded into a report-design object that is thenserialized and stored on disk (net.sf.jasperreports.engine.JasperReport). This serialized objectis used when the application wants to fill the specified report-design with data. In fact, thecompilation of a report-design implies the compilation of all Java expressions defined in theXML file representing the report design. Various verifications are made at compilation time,to check the report-design consistency. The result is a ready-to-fill report-design that will beused to generate documents on different sets of data.
 
 JB’s Collection
Page No
2 of 18
In order to fill a report-design, one can use the fillReportXXX() methods exposed by thenet.sf.jasperreports.engine.JasperManager class. Those methods receive as a parameter thereport-design object, or a file representing the specified report-design object, in a serializedform, and also a JDBC connection to the database from which to retrieve the data to fill thereport with. The result is an object that represents a ready-to-print document(net.sf.jasperreports.engine.JasperPrint) and that can be stored on disk in a serialized form(for later use), can be delivered to the printer or to the screen, or can be transformed into aPDF, HTML, XLS, CSV or XML document.Contents  Next >>
JasperReports Tutorial - API Overview
Main classes to use when working with JasperReports
net.sf.jasperreports.engine.JasperCompileManagernet.sf.jasperreports.engine.JasperFillManagernet.sf.jasperreports.engine.JasperPrintManagernet.sf.jasperreports.engine.JasperExportManager
These classes represent a façade to the JasperReports engine. They have various staticmethods that simplify the access to the API functionality and can be used to compile an XMLreport design, to fill a report, to print it, or to export to PDF, HTML and XML files.
net.sf.jasperreports.view.JasperViewer
This can be used to view the generated reports.
net.sf.jasperreports.view.JasperDesignViewer
 This can be used to view the report design.
JasperReports Tutorial - Report Designs
As mentioned, a report design represents a template that will be used by the JasperReportsengine to deliver dynamic content to the printer, to the screen or to the Web. Data stored inthe database is organized according to the report design to obtain ready to print, page orienteddocuments.The report designs are defined in XML files and must have a special structure. This structureis declared in a DTD file supplied with the JasperReports engine. The XML files are thencompiled, in order to use them in report filling operations.To create a simple report design, we have to edit an XML file with the following structure:
<?xml version="1.0"?><!DOCTYPE jasperReportPUBLIC "-//JasperReports//DTD Report Design//EN""http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> <jasperReport name="name_of_the_report" ... >...</jasperReport>
 
 JB’s Collection
Page No
3 of 18
JasperReports Tutorial - Compiling Report Designs
A report design is represented by an XML file that has the structure defined in the jasperreport.dtd file. In order to generate reports according to such a report design, it needs to be compiled. Report design compilation can be done using the compileReportXXX() methodsexposed by net.sf.jasperreports.engine.JasperCompileManager class. When compiling a report design, the engine first performs a validation to ensure that the template is consistentand then transforms all the report expressions, so that they are stored in a ready-to-evaluateform, inside the resulting .jasper file. This transformation implies either the on-the-flycompilation of a Java class file that will be associated with the report template, or thegeneration of aBeanShell script to use when evaluating report expressions during the report filling process. To make report design compilation process as flexible as possible, a specialinterface called net.sf.jasperreports.engine.design.JRCompiler was introduced. As seenabove, there are two main types of classes implementing this interface and thus performingreport compilation: 1. Java class generating report compilers. These report compilers generateand compile a Java class containing the report expressions evaluating methods; 2. TheBeanShell report compiler that generates a script for runtime report expressions evaluation,without requiring bytecode Java compilation. System properties to customize reportcompilation: jasper.reports.compiler.class By default, when compiling report designs, thelibrary tries to identify the Java generating class type of a report compiler that is compatiblewith the Java compiler available on the running platform in this order: JDK 1.3 compatiblecompiler, JDK 1.2 compatible compiler and the command-line javac.exe compiler. Tooverride this default behavior, you can specify the name of a class that implements thenet.sf.jasperreports.engine.design.JRCompiler interface to be used to compile the reportdesign by supplying it to the jasper.reports.compiler.class system property. The library comeswith 5 built-in implementations of this interface:net.sf.jasperreports.engine.design.JRJavacCompiler net.sf.jasperreports.engine.design.JRJdk12Compiler net.sf.jasperreports.engine.design.JRJdk13Compiler net.sf.jasperreports.engine.design.JRJdtCompiler   net.sf.jasperreports.engine.design.JRJikesCompiler Note that the classes implementing the JRCompiler interface can also be used directly in the programs without the need to call themthrough the faæ ¤eJasperCompilerManager class. jasper.reports.compilation.xml.validationThe XML validation, which is ON by default, can be turned off by setting the system property called jasper.reports.compilation.xml.validation to false. When working with a Java

Activity (29)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
Jeanne Daisy liked this
ALi liked this
Mbengue Hoge liked this
jayavardhankoti liked this
rams1234567890 liked this
sureshggg liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->