导出控件全面处理报表的导出。它使您可以在浏览器窗口中预览导出的报表,或将报表作为附件导出,并通过显示一个下载对话框来提示用户。导出控件由 ReportExportControl 类表示。
<%@ 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" %>
ReportExportControl exportControl = new ReportExportControl();
一旦创建了 ReportExportControl
对象,就必须指定想要的导出格式。对于本例而言,选择了 RTF 作为导出格式。有关导出格式的完整列表,请参阅导出格式。
ExportOptions exportOptions = new ExportOptions();
exportOptions.setExportFormatType(ReportExportFormat.RTF);
注意: 有关指定导出格式的有效常量的列表,可以在《Crystal Reports for Rational Application Developer Java API 参考》中的 ReportExportFormat 类文档中找到。
某些格式包含附加的选项,可以通过配置这些选项来自定义如何导出报表。例如,可以控制为某些格式导出的页面范围。
在本例中,创建一个 RTFWordExportFormatOptions 对象,这是因为导出格式为 RTF。
RTFWordExportFormatOptions RTFExpOpts = new RTFWordExportFormatOptions();
RTFExpOpts.setStartPageNumber(1);
RTFExpOpts.setEndPageNumber(3);
exportControl.setReportSource(reportSource);
exportControl.setExportOptions(exportOptions);
将此方法设置为 true 会显示一个对话框,该对话框允许您的 Web 应用程序的用户在打开导出的报表前保存它。否则,如果浏览器支持对导出的文件类型进行打开,则导出的报表会直接显示在浏览器窗口中。
Business Objects http://www.china.businessobjects.com 支持服务 http://www.china.businessobjects.com |