+ All Categories
Home > Software > Jasper Report - Lesson

Jasper Report - Lesson

Date post: 11-Feb-2017
Category:
Upload: alex-fernandez
View: 330 times
Download: 3 times
Share this document with a friend
13
JASPER REPORTS - EXPLAINED
Transcript
Page 1: Jasper Report - Lesson

JASPER REPORTS - EXPLAINED

Page 2: Jasper Report - Lesson

THE LIBRARY Can be downloaded at

http://sourceforge.net/projects/jasperreports/?source=directory

Page 3: Jasper Report - Lesson

LINKING THE LIBRARIES

Page 4: Jasper Report - Lesson

CREATING A REPORTS STARTS WITH A TEMPLATE

Page 5: Jasper Report - Lesson

HELLO.JRXML

Page 6: Jasper Report - Lesson

LINKING TO WINDOWS FORMS[THE CODE]

Page 7: Jasper Report - Lesson

CONNECT TO THE DATABASE

Page 8: Jasper Report - Lesson

THE FORM

Page 9: Jasper Report - Lesson

THE KOWD

import net.sf.jasperreports.engine.*;

import net.sf.jasperreports.view.*;

import javax.sql.*;

import java.util.HashMap;

Page 10: Jasper Report - Lesson

ESSENTIAL METHODS

JasperCompileManager.compileReport —

The compileReport method takes the JasperReports XML template and compiles it into byte code format (a JasperReports instance), which you can serialize to disk as a .jasper file. You can reuse the compiled templates to generate reports without compiling them unless you've changed the template source. This is similar to the difference between a .jsp file and its compiled servlet class counterpart.

Page 11: Jasper Report - Lesson

JasperFillManager.fillReport — The fillReport method takes the compiled report (the JasperReports instance), a few user-defined custom parameters, and a JasperReports datasource (an empty instance—more on that later), and fills the report instance with the parameters and data, if any. In this simple static Hello Report World! example, the method fills in nothing but returns an instance of JasperPrint instead.

The JasperPrint instance is an object representation of the completed report. Now all you have to do is instruct JasperReports to write it to disk in the desired and supported formats.

Page 12: Jasper Report - Lesson

JasperExportManager.exportReportToHtmlFile — The exportReport method takes the JasperPrint instance and a destination file path and creates an HTML file with the report content. Besides HTML, the JasperReports framework supports exporting to PDF, XML, CSV (comma-separated values), XLS, RTF, and text file formats. You can also create custom file formats for export with the extensible JasperReports API.

Page 13: Jasper Report - Lesson

JasperExportManager.viewReport — The viewReport method displays the generated report in the built-in JasperReport Viewer. This is an optional but handy display that enables you to quickly see how a report looks without opening the generated files.


Recommended