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.
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 the Export formats section.
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.
Some formats contain additional options that can be configured to customize how the report is exported. This includes control over what page range is exported and so on.
In this case, because the export format is RTF, a RTFWordExportFormatOptions object is created.
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 causes the Export Control to display a dialog box that allows users of your web application to save the exported report before they open it. Otherwise, the exported report is displayed in the browser window directly.
exportControl.setExportAsAttachment(true);
| Crystal Decisions http://www.crystaldecisions.com/ Support services http://support.crystaldecisions.com/ |