Académique Documents
Professionnel Documents
Culture Documents
Contents 1. 2. 3. 4. 5. 6. 7. 8. 9. Introduction iReport features Basic notions of JasperReport Building your first report Report structure Report elements Subreports Installation Refrences
2011 2
2011
1. Introduction (cont.) A report produced in iReport can be integrated in your open source or commercial application to Generate reports Display them on screen Export them in several formats including PDF, OpenOffce, DOCX, and many others. Send the final document directly to a printer.
What is JasperReports?
The open source reporting engine available for java community.
2011
2011
4/26/2011
1. Introduction (cont.)
2. iReport features Simple to use GUI Report designer and tools Data sources Report templates Export and review
2011
2011
3. Basic notions of JasperReport The report life cycle Jrxml sources and jasper files Data sources and print formats Expressions A simple program
Program java
*.jrxml *.dtd
Program class
Complier
*.jasper
Complier
1011
Interpreter
00111
Interpreter
Computer
2011
2011
4/26/2011
Report src
*.jasper
Complier
00111
Interpreter
2011
2011
10
3.4 Expressions All of the formulas in JasperReports are defined through expressions
2011
11
2011
12
4/26/2011
3.4 Expressions (cont.) An expression is a java instruction which has an object as a result Expression examples are the following:
This is an expression new Boolean(true) new Integer(3) (($P{MyParam}.equals(S)) ? Yes : No)
13
2011
14
4. Building your first report Creating a new data source or database JDBC connection Creating a report using the wizard Using the design query feature to produce the SQL query for the report Viewing and exporting the report using the builtin viewer
5. Report structure Title Page header Column header Group header Detail Group footer Column footer Page footer Last page footer Summary Background
2011 16
2011
15
4/26/2011
2011
17
2011
18
6. Report elements The basic elements offered by the JasperReports library: Line Rectangle Ellipse Static text Text field (or simply Field) Image Subreport
Software Engineering Department 2011 19
Variables
To calculate something during the runtime of the report.
Parameters
To pass data to the report engine. The data may be passed from another report, from any program, or directly from the user.
Groups
2011
20
4/26/2011
6.1 Fields
6.2 Variables The properties of a variable: Name Variable class Calculation Reset type Reset group Variable Expression
2011
21
2011
22
6.3 Parameters The properties of a parameter Name Parameter Class Use as a prompt Default Value Expression
6.3 Parameters (cont.) HashMap hm = new HashMap(); hm.put(Parameter_Name, 2); ... JasperPrint print = JasperFillManager.fillReport( fileName, hm, new JREmptyDataSource());
2011
23
2011
24
4/26/2011
6.4 Groups Add group Delete group Variables for the group
7. Subreports A subreport is a complete report that is placed in another report. If you've got one item that is linked to several items in another table, such as a department and its employees, then a subreport is what you need. In such cases, generally, the main report (where the subreport is placed) contains the data of the master/parent table, and the subreport contains the data of the detail/child table.
25 Software Engineering Department 2011 26
2011
7. Subreports (cont.) Creating the master report Creating the subreport Returning values from the subreport
8. Installation JDK 6 (link). MySQL 5.x (link). MySQL GUI tools (link). iReport (link).
Must add the files to library of the project commons-collections-xxx.jar commons-digester-xxx.jar, commons-logging-xxx.jar, jasperreports-xxx.jar.
(C:\Program Files\Jaspersoft\iReport-nb-3.7.0\ireport\modules\ext)
Software Engineering Department 2011 27 Software Engineering Department 2011 28
4/26/2011
9. References http://jasperforge.org/projects/ireport http://ireport-tutorial.blogspot.com iReport 3.7 Learn how to use iReport to create, design, format, and export reports
Q&A
2011
29
2011
30