导出API
报表输出为其它格式的文件既可以通过ReportExporter来进行导出,也可以使用文件流的方式来进行输出。具体代码如下:
导出文件
- 导出Excel
IReport iReport = ......; //运算代码,获得一个IReport对象
ReportExporter re = new ReportExporter(java.lang.String fileName,ReportExporter. EXPORT_EXCEL); //导出为excel
ReportExporter re = new ReportExporter(java.lang.String fileName,ReportExporter. EXPORT_EXCEL_PAGE); //导出为分页的excel
ReportExporter re = new ReportExporter(java.lang.String fileName,ReportExporter. EXPORT_EXCEL_FORMULA); //导出为带公式的excel
re.export(ireport ); //导出
- Openxml形式导出Excel
IReport iReport = ......; //运算代码,获得一个IReport对象
ReportExporter re = new ReportExporter(java.lang.String fileName,ReportExporter. EXPORT_EXCEL_OPENXML); //Openxml形式导出为excel
ReportExporter re = new ReportExporter(java.lang.String fileName,ReportExporter. EXPORT_EXCEL_OPENXML_PAGE); //Openxml形式导出为分页的excel
ReportExporter re = new ReportExporter(java.lang.String fileName,ReportExporter. EXPORT_EXCEL_OPENXML_FORMULA); //Openxml形式导出为带公式的excel
re.export(ireport ); //导出
- 导出Word
IReport iReport = ......; //运算代码,获得一个IReport对象
ReportExporter re = new ReportExporter(java.lang.String fileName,ReportExporter. EXPORT_WORD); //导出为word
ReportExporter re = new ReportExporter(java.lang.String fileName,ReportExporter. EXPORT_WORD_PAGE); //导出为分页的word
re.export(ireport ); //导出
- 导出Pdf
IReport iReport = ......; //运算代码,获得一个IReport对象
ReportExporter re = new ReportExporter(java.lang.String fileName,ReportExporter. EXPORT_PDF); //导出为pdf
ReportExporter re = new ReportExporter(java.lang.String fileName,ReportExporter. EXPORT_PDF_PAGE); //导出为分页的pdf
re.export(ireport ); //导出
- 导出Text
IReport iReport = ......; //运算代码,获得一个IReport对象
ReportExporter re = new ReportExporter(java.lang.String fileName,ReportExporter. EXPORT_TEXT); //导出为txt
re.export(ireport ); //导出
- 导出xml
IReport iReport = ......; //运算代码,获得一个IReport对象
ReportExporter re = new ReportExporter(java.lang.String fileName,ReportExporter.EXPORT_XML); //导出为xml
re.export(ireport ); //导出
- 导出Html
IReport iReport = ......; //运算代码,获得一个IReport对象
ReportExporter re = new ReportExporter(java.lang.String fileName,ReportExporter. EXPORT_HTML); //导出为html
re.export(ireport ); //导出
输出报表
- 输出到word
ReportUtils.exportToDOC(java.io.OutputStream os, IReport report);
ReportUtils.exportToDOC(java.lang.String fileName, IReport report);
- 输出到excel
ReportUtils.exportToExcel(java.io.OutputStream os, IReport report, boolean pageBroken);
ReportUtils.exportToExcel(java.io.OutputStream os, IReport report, boolean pageBroken, int dispRatio);
ReportUtils.exportToExcel(java.lang.String fileName, IReport report, boolean pageBroken);
ReportUtils.exportToExcel(java.lang.String fileName, IReport report, boolean pageBroken, int dispRatio);
- 输出到OpenXml格式的excel
ReportUtils.exportToExcelOpenXML(java.io.OutputStream os, IReport report, java.lang.String sheetName, boolean exportFormula)
ReportUtils.exportToExcelOpenXML(java.lang.String fileName, IReport report, java.lang.String sheetName, boolean exportFormula)
- 输出到html
ReportUtils.exportToHTML(java.lang.String fileName, IReport report);
ReportUtils.exportToHTML(java.lang.String fileName, IReport report, float scale);
ReportUtils.exportToHTML(java.lang.String fileName, IReport report, java.lang.String encode, float scale);
- 输出到pdf
ReportUtils.exportToPDF(java.io.OutputStream os, IReport report);
ReportUtils.exportToPDF(java.lang.String fileName, IReport report);
- 输出到text
ReportUtils.exportToText(java.io.OutputStream os, IReport report);
ReportUtils.exportToText(java.io.OutputStream os, IReport report, java.lang.String separator, boolean dispValue);
更加灵活的输出方法
这里仅以excel为例