0% found this document useful (0 votes)
75 views7 pages

Jasper Reports

Jasper Reports for java deveoper

Uploaded by

kasim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views7 pages

Jasper Reports

Jasper Reports for java deveoper

Uploaded by

kasim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

JAVA Means DURGA SOFT

-------------------------------------------------------------------------------------------------------
DURGA SOFTWARE SOLUTIONS ,202 HUDA Maitrivanam, Ameerpet , Hyd. Ph: 040-64512786 Page 1
JAVA Means DURGA SOFT

Jasper Reports
Introduction:
Jasper Reports is a popular open-source reporting engine whose
main purpose is to help creating page oriented, ready to print documents in a simple
and flexible manner. Jasper Reports is written in 100% Java and can be embedded
in any Java application. Jasper Reports has the ability to deliver rich content in
various formats such as PDF, HTML, XLS, CSV, XML files, or directly on the
screen or printer.

Jasper Reports is distributed under two licenses, an Apache-style license and


the LGPL license. Due to its flexible licensing, JasperReports is the perfect
candidate to complete the reporting features for any commercial or open-source
application.

Steps To design Reports Based on Jasper Reports:


a) Preparing .jrxml file & compiling the .jrxml file:
Jasper Reports organizes data retrieved from a data source according to
a report-design defined in a JRXML file. In order to fill a report with data, the
report-design must be compiled first.
The compilation of the JRXML file representing the report-design is
performed by the compileReport() method exposed by the JasperCompileManager
class.

Through compilation, the report design is loaded into a report-design object


that is then serialized and stored on disk (Jasper Report class). This serialized object
is used when the application wants to fill the specified report-design with data. In
fact, the compilation of a report-design implies the compilation of all Java
expressions defined in the JRXML 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 be used to generate documents on
different sets of data.

-------------------------------------------------------------------------------------------------------
DURGA SOFTWARE SOLUTIONS ,202 HUDA Maitrivanam, Ameerpet , Hyd. Ph: 040-64512786 Page 2
JAVA Means DURGA SOFT

Eg:
<!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report
Design//EN"
"http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport name="Simple_Report">
<detail>
<band
height="2
0">
<staticTex
t>
<reportElement x="180" y="0" width="200"
height="20"/> <text><![CDATA[Hello
World!]]></text>
</staticText>
</band>
</detail>
</jasperReport>

<jasperReport> - the root element.

<title> - its contents are printed only once at the beginning of the report
<pageHeader> - its contents are printed at the beginning of every page in
the report.

-------------------------------------------------------------------------------------------------------
DURGA SOFTWARE SOLUTIONS ,202 HUDA Maitrivanam, Ameerpet , Hyd. Ph: 040-64512786 Page 3
JAVA Means DURGA SOFT

<detail> - contains the body of the report.

<pageFooter> - its contents are printed at the bottom of every page in the
report.

<band> - defines a report section, all of the above elements contain a band
element as its only child element.

b) Fill The Report:

In order to fill a report-design, one can use the fillReportXXX () methods


exposed by the JasperFillManager class. Those methods receive as a parameter
the report-design object, or a file representing the specified report-design object,
in a serialized form, and also a JDBC connection to the database from which to
retrieve the data to fill the report with. The result is an object that represents a
ready-to-print document ( Jasper Print class) 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
exported into a PDF, HTML, XLS, RTF, ODT, CSV, TXT or XML document.

As you can see, the main classes to use when working with JasperReports are:
net.sf.jasperreports.engine.JasperCompileManager
-------------------------------------------------------------------------------------------------------
DURGA SOFTWARE SOLUTIONS ,202 HUDA Maitrivanam, Ameerpet , Hyd. Ph: 040-64512786 Page 4
JAVA Means DURGA SOFT

net.sf.jasperreports.engine.JasperFillManager
net.sf.jasperreports.engine.JasperPrintManager
net.sf.jasperreports.engine.JasperExportManager

These classes represent a façade to the Jasper Reports engine. They have various
static methods that simplify the access to the API functionality and can be used to
compile an JRXML report design, to fill a report, to print it, or to export to other
document formats (PDF, HTML, XML).

c) View, Print and Export Reports:

Generated reports can be viewed using the JasperViewer application. In its main ()
method, it receives the name of the file which contains the report to view.

Generated reports can be printed using the printReport(), printPage() or


printPages() static methods exposed by the JasperPrintManager class.

After having filled a report, we can also export it in PDF, HTML or XML format
using the exportReportXXX() methods of the JasperExportManager class.

-------------------------------------------------------------------------------------------------------
DURGA SOFTWARE SOLUTIONS ,202 HUDA Maitrivanam, Ameerpet , Hyd. Ph: 040-64512786 Page 5
JAVA Means DURGA SOFT

-------------------------------------------------------------------------------------------------------
DURGA SOFTWARE SOLUTIONS ,202 HUDA Maitrivanam, Ameerpet , Hyd. Ph: 040-64512786 Page 6
JAVA Means DURGA SOFT

-------------------------------------------------------------------------------------------------------
DURGA SOFTWARE SOLUTIONS ,202 HUDA Maitrivanam, Ameerpet , Hyd. Ph: 040-64512786 Page 7

You might also like