Java Reference
In-Depth Information
The Document Type Definition (DTD) for the generated XML when exporting
to this format can be found at http://jasperreports.sourceforge.net/dtds/
jasperprint.dtd .
Reports exported to XML can be viewed with the JasperViewer utility included with
JasperReports. To view a report exported to XML, the -XML argument needs to be
passed to JasperViewer. For example, to view the above XML report, the following
. For example, to view the above XML report, the following
command needs to be typed in the command line (assuming all required libraries are
already in the CLASSPATH):
JasperViewer. For example, to view the above XML report, the following
net.sf.jasperreports.view.JasperViewer -Freports/DatasetDemoReport.
jrpxml -XML
Exporting reports to XML has some advantages over using the compiled report
directly. For example, exported reports are human readable and editable, and they can
easily be stored in a database without resorting to BLOBS (Binary Large Objects) .
Exporting to CSV
CSV (Comma Separated Values) files contain a number of values separated by
commas. There are several pieces of software that can parse CSV files. JasperReports
includes built-in functionality to export reports to CSV files. The following example
illustrates the process:
package net.ensode.jasperbook;
import java.io.File;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.export.JRCsvExporter;
import net.sf.jasperreports.engine.util.JRLoader;
public class CsvExportDemo
{
public static final String REPORT_DIRECTORY = "reports";
public void csvExport(String reportName)
{
File file = new File(REPORT_DIRECTORY + "/" + reportName +
".jrprint");
try
 
Search WWH ::




Custom Search