Java Reference
In-Depth Information
After successful execution of the compile target, we should have a
FirstReport.jasper
file in the file system. This file is identical to the one
generated programmatically by calling the
net.sf.jasperreports.engine.
JasperCompileManager.compileReportToFile()
.
As can be seen in the output above, the JRC target will generate
a
log4j
warning. This warning can be safely ignored.
As explained in the previous section, we can preview the generated Jasper file by
using the JasperDesign utility included by JasperReports. The output will be identical.
Generating the Report
In JasperReports lingo, the process of generating a report from a report template,
or Jasper file, is known as
illing
the report. Reports are filled programmatically, by
calling the
fillReportToFile()
method in the
net.sf.jasperreports.engine.
JasperFillManager
class. The
fillReportToFile()
method fills a report and saves
it to disk.
There are six overloaded versions of the
fillReportToFile()
method, which are
listed below:
JasperFillManager.fillReportToFile(JasperReport
jasperReport
,
String
destFileName
,
Map
parameters
,
Connection
connection)
JasperFillManager.fillReportToFile(JasperReport
jasperReport
,
String
destFileName
,
Map
parameters
,
JRDataSource
datasource)
JasperFillManager.fillReportToFile(String
sourceFileName
,
Map
parameters
,
Connection
connection)
JasperFillManager.fillReportToFile(String
sourceFileName
,
Map
parameters
,
JRDatasource
dataSource)
JasperFillManager.fillReportToFile(String
sourceFileName
,
String
destFileName
,
Map
parameters
,
Connection
connection)
JasperFillManager.fillReportToFile(String
sourceFileName
,
String
destFileName
,
Map
parameters
,
JRDataSource
dataSource)
•
•
•
•
•
•