Jasper Report总结

阅读更多

下载

Jasper:

       http://jasperforge.org/website/jasperreportswebsite/trunk/index.html

IReport:

       http://sourceforge.net/projects/ireport/

结构

net.sf.jasperreports.engine.design.JasperDesign --> jrxml 文件

                            ||

                            || 编译

                            \/

net.sf.jasperreports.engine.JasperReport --> jasper 文件

                            ||

                            || 填充

                            \/

net.sf.jasperreports.engine.JasperPrint --> jrprint 文件

              ||                          ||                    ||           

              || 导出                || 显示            || 打印

              \/                          \/                   \/

       html, PDF, excel           panel      

操作

1.        编译

JasperCompileManager

              .compileReport/compileReportToFile/compileReportToStream

n         输入 : inputStream/jasperDesign/jrxmlFileName

n         输出 ( 可选 ) outputStream(ToStream), jasperFileName(ToFile)

n         e.g. JasperCompileManager.compileReportToFile("sample_report.jrxml","sample_report.jasper");

2.        填充

JasperFillManager

              .fillReport/fillReportToFile/fillReportToStream

n         输入 : inputStream/jasperReport/jasperFileName

n         输出 ( 可选 ) outputStream(ToStream), jrprintFileName(ToFile)

n         参数: Map parameters

n         数据连接 ( 可选 ) connection/dataSource

n         e.g. JasperFillManager.fillReportToFile("sample_report.jasper", "sample_report.jrprint", null, new JREmptyDataSource());

3.        导出

JasperExportManager

.exportReportToHtmlFile/exportReportToPdf/exportReportToPdfFile/exportReportToPdfStream/exportReportToXml/exportReportToXmlFile/exportReportToXmlStream

n         输入 : jasperPrint/sourceFileName

n         输出 ( 可选 ) outputStream(ToStream), destFileName(ToFile)

n         参数: Map parameters

n         数据连接 ( 可选 ) connection/dataSource

n         e.g. JasperFillManager.fillReportToFile("sample_report.jasper", "sample_report.jrprint", null, new JREmptyDataSource());

net.sf.jasperreports.engine.export.JR CsvExporter

JRPdfExporter

JRHtmlExporter

JRRtfExporter

JRTextExporter

JRXmlExporter

n         设置参数 e.g      

exporter.setParameter(JRExporterParameter.JASPER_PRINT,

jasperPrint);

exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFileName);

n         导出 exporter.exportReport();     

4.        显示

JRViewer

n         输入: inputStream/jasperReport/jasperFileName

n         是否是 XML isXML

n         地域: Locale

n         e.g. JPanel p = new JRViewer("sample_report.jrprint",false);

5.        打印

JasperPrintManager                       .printReport/printPageToImage/printPages/printPage/printReportToPdf/printReportToPdfFile/printReportToPdfStream/printReportToXml/printReportToXmlFile/printReportToXmlStream

n         输入 : jasperPrint/sourceFileName/inputStream

n         输出 ( 可选 ) outputStream(ToStream), destFileName(ToFile)

n         e.g. JasperPrintManager.printReport("sample_report.jrprint",false);   

6.        执行 = 填充 + 输出

JasperRunManager

              .runReportToHtmlFile/runReportToPdf/runReportToPdfFile/runReportToPdfStream

n         输入 : inputStream/jasperReport/jasperFileName

n         输出 ( 可选 ) htmlFileName(ToHtmlFile), pdfFileName(ToPdfFile), outputStream(ToPdfStream)

n         参数: Map parameters

n         数据连接 ( 可选 ) connection/dataSource

7.        文件 ->Jasper 对象

       net.sf.jasperreports.engine.util.JRLoader.loadObject(inputStream/File/FileName)

模板

$P{key} -> paraMap (key, value

$R{key} -> messageBundle (key, value

$F{fieldName} ->

$V{varName}

你可能感兴趣的:(.net,Excel,数据结构,XML,HTML)