The export control handles all aspects of exporting the report. It allows you to preview the exported report within the browser window or export it as an attachment, prompting the user with a download dialog. The export control is represented by the ReportExportControl class.
<%@ 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();
Once you have created the ReportExportControl object, you must specify the export format that you want. For the purpose of this example, RTF has been chosen as the export format. For a complete list of export formats, see Viewer features.
ExportOptions exportOptions = new ExportOptions();
exportOptions.setExportFormatType(ReportExportFormat.RTF);
Note: A list of the valid constants specifying export formats can be found in the ReportExportFormat class documentation located in the Crystal Reports Toolkit for the Rational Software Development Platform API Reference.
Some formats contain additional options that can be configured to customize how the report is exported. For example, you can control the page range that is exported for some formats.
In this case, a RTFWordExportFormatOptions object is created because the export format is RTF.
RTFWordExportFormatOptions RTFExpOpts = new RTFWordExportFormatOptions();
In this example, the export options are configured so that only pages 1 to 3 are exported.
RTFExpOpts.setStartPageNumber(1);
RTFExpOpts.setEndPageNumber(3);
exportOptions.setFormatOptions(RTFExpOpts);
exportControl.setReportSource(reportSource);
exportControl.setExportOptions(exportOptions);
Setting this method to true displays a dialog box that allows users of your web application to save the exported report before they open it. Otherwise, if the browser supports opening the exported file type, the exported report is displayed in the browser window directly.
exportControl.setExportAsAttachment(true);
Business Objects http://www.businessobjects.com/ Support services http://www.businessobjects.com/services/support/ |