Java Reference
In-Depth Information
Exporting to RTF
Rich Text Format (RTF) is a document file format that is supported by most word
processors. Exporting to RTF allows our documents to be read by Microsoft Word
and several other word processors.
Unfortunately, RTF documents generated by JasperReports
are not always readable by or StarOffice writer, since
these office suites are not fully compliant with the RTF specification.
In the following example, we will export a report to RTF format.
package net.ensode.jasperbook;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.export.JRRtfExporter;
import net.sf.jasperreports.engine.util.JRLoader;
public class RtfExportDemo
public static final String REPORT_DIRECTORY = "reports";
public void rtfExport(String reportName)
File file = new File(REPORT_DIRECTORY + "/" + reportName +
JasperPrint jasperPrint = (JasperPrint)
JRRtfExporter rtfExporter = new JRRtfExporter();
JASPER_PRINT, jasperPrint);
REPORT_DIRECTORY + "/" + reportName + ".rtf");
System.out.println("Exporting report...");
Search WWH ::

Custom Search