• Home
  • Contact Me
  • About Me
  • Resources
  • Favorites
  • Earn Money

Friday, May 16, 2008

EGL: Integrating Jasper Report

­­This section describes how to integrate the Jasper reports to the Enterprise Generation Language EGL Web application.

Required library files:-
1) The following jar files need to be included in the Web-INF – lib
a. Jasper-Reports 2.0.5.jar
b. iText.jar – for PDF format to be output.

Steps for integration of Jasper file into the application:-
1) The jasper file generated earlier has to be included in the Java resource folder of the application.
2) Create an array for holding the data of the report.
3) Export the report using the “Report” and “Report Data” object.

Initialize the report data object:-
a. Data – assign the report data array to the data property of the report data object.

Initialize the following properties of the report object:-

a. reportDesignFile – Path of the jasper file(.jasper file).
b. reportDestinationFile – Path of the temporary report file (.jrprint file).
c. reportData – assign the report data object to this property.
d. reportExportFile – Name of the file to which the report has to be exported.

Call ReportLib functions:-
a. FillReport method – send the report object and Datasource.reportData as parameters to this method.
b. exportReport method – send the report object and the export format as parameters to this method. Available export formats are - “html”, “pdf”,”text”,”csv”,”xml”.


Code Snippet:-
//report object


report Report = new Report();
//report data object
reportData ReportData = new ReportData();
//jasper file location
report.reportDesignFile = jasperLocation;
//temp file location
report.reportDestinationFile = reportFileLocation + exportFileName + ".jrprint";
//assign data array to report data object
reportData.data = <>;
//assign data to report
report.reportData = reportData;
//complete report file location
filePathName string = reportFileLocation + reportFileName;
//assign the export file name
report.reportExportFile = filePathName;
//fill the report
ReportLib.fillReport(report, DataSource.reportData);
//Export report to the required formatReportLib.exportReport(report, ExportFormat.html);


Monu

No comments: