Exporting to XML

JasperReports uses a Document Type Definition (DTD) file to generate XML reports. XML reports can be exported back to the compiled reports by using the net.sf.jasperreports.engine.xml.JRPrintXmlLoader class. The following example demonstrates how to export a report to XML:

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.JRXmlExporter;
import net.sf.jasperreports.engine.util.JRLoader;

public class XmlExportDemo
{
  public static final String REPORT_DIRECTORY = "reports";
  public void xmlExport(String reportName) { File file = new File(REPORT_DIRECTORY ...

Get JasperReports 3.5 for Java Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.