Java Reference
In-Depth Information
JasperFillManager.fillReportToFile(String sourceFileName , Map parameters ,
JRDataSource dataSource)
The following Java class fills the report and saves it to disk:
package net.ensode.jasperbook;
import java.util.HashMap;
import net.sf.jasperreports.engine.JREmptyDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
public class FirstReportFill
public static void main(String[] args)
System.out.println("Filling report...");
new HashMap(), new JREmptyDataSource());
catch (JRException e)
After executing the above class, we should have a file named FirstReport.
JRprint in the same location as our compiled report template, which was named
FirstReport.jasper .
Viewing the Report
JasperReports includes a utility class, net.sf.jasperreports.view.JasperViewer ,
that we can use to view generated reports. As with the tool to preview designs, the
easiest way to use it is to wrap it into an ANT target. Again, this is the approach
taken by the samples included with JasperReports, and the approach taken by us
as well. Let us add a new target to our ANT build file. Following the conventions
established by the JasperReports samples, we will name this target view .
Search WWH ::

Custom Search