Slide 1 - SSDT Public Wiki

streakconvertingΛογισμικό & κατασκευή λογ/κού

13 Δεκ 2013 (πριν από 3 χρόνια και 3 μήνες)

69 εμφανίσεις


Open Source Reporting Engine


Reporting Engine & Compiler

Various Input Options

XML, Hibernate,

Various Output Options

PDF, Excel, HTML,

Ability to create Charts


Report GUI Design tool

In Compiler to create compiled reports


JRE 1.4 or higher

Commons Beanutils

Commons Collections

Commons Logging

Commons Digester


for PDF output


for Microsoft formats


if using Charts/Graphs

Ant Task

Ant task is located in
Tools that will compile

Add to build.xml to
enable Jasper
compiling on build

iReport/Making Report Definition

Located in Tools

File Types:


report definition (xml format)


compiled report definition

iReport can open either version

Basic Report Layout

Each section of the report is called a band

Different bands will print different sections of the

Bands can be added, removed and resized

Not all bands are always used

Fields can be moved, stretched and resized
using the mouse.

Types of Fields

Static Text

data fields, i.e.
Headings, titles, labels, etc.

Text fields

can be data and/or non


used for calculating of fields


passed into the report at
compile time

New Text Field



Click New

Enter the field name

this will define it in the

Select Class Type

String is text fields,
BigDecimal for
amount fields















Record Path is: /CompleteReceipt/Receipt/Item

Field Description

The field description field is the path to the
data from the record path

If we have a receipt, with items, it’s record
path is: /CompleteReceipt/Receipt/Item

To access the Receipt number, the field
description would be: ../number (the ..
will go up the tree)

If a CompleteReceipt piece of data is
needed, it would be: ../../data

Adding a Variable


Variables, and
click New.

Enter a variable name.

Choose calculation type,
Add, multiply, etc.

Class type and
Expressions should be of
BigDecimal type

Adding a Parameter


click New

Enter name and
select class type.

These are passed
into the report at
compile time.


A separate .jasper file that is used inside
of another report.

A data source can be applied to a
subreport in the report properties as
shown here:

Subreports, cont.

Parameters are
defined on the
Subreport (other) tab.

The subreport
Expression field will
be the path to the
subreport. We pass
these in via a

Compile Report


Compile will build the report, and
create a .jasper file. This file will be used
in the java code.

Ant task will also do this if added to build

Back to Java Code

Now, our .jasper files are created. Time to
compile them with the data.

Need the following imports (using XML data
source and PDF output):

Creating Final report

First we need to get our jasper files, main
report and any subreports:

In USASWeb, we keep the paths to these
files in StrutsResources.

Creating Final report, cont.

Now, we need to create an ArrayList for
our report(s) and a Hashmap for any

A parameter needs the parameter name,
and then the data to send.

Creating Final report, cont.

Now, we can get our data. This shows an xml,
being input thru a ByteArrayInput Stream.

The Xml data source needs an input stream,
and the record path. (can also take in a File,
Document, JDBC connection)

Creating Final report, cont.

Now, we fill the report. We need to pass
in the main reports path, our parameters
and the data source.

Then, we can add the report to our
PrintList. (if using PDF bookmarks or to
set the spreadsheet name in Excel, use
the setName method)

Creating Final report, cont.

Now, we have our report made, now time
to export it. I will show the PDF exporter.

First, create a new PDFExporter instance,
and get the response ready for our output.

Finally, the report is done!

Now, we set the exporter parameters.
Here, we need our PrintList, output
method, and since we are using PDF
bookmarks, we need to set the flag.

Finally, we export the report.


Now, it will be output to the browser.