导出报表

本课程演示如何将 Crystal 报表导出为不同的格式。JRC 可以使用的导出格式有:可移植文档格式(PDF)、RTF 格式(RTF)、可编辑 RTF、逗号分隔值(CSV)和 Crystal Reports 格式。对于本教程而言,选择了 RTF 作为导出格式。

导出 Crystal Reports 报表
  1. “项目资源管理器”视图中,转到 CrystalReportsDemo\WebContent。右击 WebContent 并单击“新建”>“JSP”
  2. 此时将打开“新建 JavaServer 页”对话框。

  3. “文件名”字段中,键入 ExportReport.jsp
  4. 单击“完成”
  5. 双击 ExportReport.jsp 以打开该文档。
  6. 输入以下代码段:
  7. <%@page import="com.crystaldecisions.reports.sdk.*" %>

    <%@page import="com.crystaldecisions.sdk.occa.report.reportsource.*" %>

    <%@page import="com.crystaldecisions.sdk.occa.report.lib.*" %>

    <%@page import="com.crystaldecisions.sdk.occa.report.exportoptions.*" %>

    <%@page import="com.crystaldecisions.report.web.viewer.*"%>

    <%

    ReportClientDocument reportClientDoc = new ReportClientDocument();

    String report = "/Sample Reports/Customer Profile Report.rpt";

    reportClientDoc.open(report, 0);

    Object reportSource = reportClientDoc.getReportSource();

    ReportExportControl exportControl = new ReportExportControl();

    ExportOptions exportOptions = new ExportOptions();

    exportOptions.setExportFormatType(ReportExportFormat.RTF);

    RTFWordExportFormatOptions RTFExpOpts = new RTFWordExportFormatOptions();

    RTFExpOpts.setStartPageNumber(1);

    RTFExpOpts.setEndPageNumber(3);

    exportOptions.setFormatOptions(RTFExpOpts);

    exportControl.setReportSource(reportSource);

    exportControl.setExportOptions(exportOptions);

    exportControl.setExportAsAttachment(true);

    exportControl.processHttpRequest(request, response, getServletConfig().getServletContext(), out);

    %>

    注意:
       
    此代码段会将 Customer Profile Report.rpt 导出为 RTF。

  8. 右击 ExportReport.jsp,然后单击“运行方式”>“在服务器上运行”
  9. 单击“完成”
  10. 此时将启动 Crystal Reports 查看器 DHTML 报表页面。

  11. 在提示时打开导出的 Crystal 报表。





Business Objects
http://www.china.businessobjects.com/

支持服务
http://www.china.businessobjects.com/services/services.htm