下例是一个简单的 JSP 页面,它演示了如何使用导出控件将报表的前三页导出为 RTF。
<%@ page import="com.crystaldecisions.report.web.viewer.ReportExportControl" %>
<%@ page import="com.crystaldecisions.reports.reportengineinterface.JPEReportSourceFactory" %>
<%@ page import="com.crystaldecisions.sdk.occa.report.reportsource.IReportSourceFactory2" %>
<%@ 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");
String report = "/reports/sample.rpt";
IReportSourceFactory2 rptSrcFactory = new JPEReportSourceFactory();
reportSource = rptSrcFactory.createReportSource(report, request.getLocale());
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 |