示例 1 - 导出报表

下例是一个简单的 JSP 页面,它演示了如何使用导出控件将报表的前三页导出为 RTF。

注意:    本例中使用的报表未随附于教程中。

exportreport.jsp

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

<%@ page import="com.crystaldecisions.reports.sdk.ReportClientDocument" %>

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

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

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

<%

    Object reportSource = session.getAttribute("reportSource");

    if (reportSource == null)

    {

       String report = "/reports/sample.rpt";

       ReportClientDocument reportClientDoc = new ReportClientDocument();

       reportClientDoc.open(report, 0);

       reportSource = reportClientDoc.getReportSource();

       session.setAttribute("reportSource", reportSource);

    }

    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(), null);

%>



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

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