Creating and initializing an Export Control

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.

To create an Export Control
  1. Instantiate a ReportExportControl object.

    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.

To specify the export format
  1. Create an ExportOptions object.

    ExportOptions exportOptions = new ExportOptions();

  2. Specify the export format by calling the ExportOptions object's setExportFormatType method, passing it a ReportExportFormat constant representing the desired format.

    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.

To configure format specific options
  1. Create the appropriate format options object.

    In this case, because the export format is RTF, a RTFWordExportFormatOptions object is created.

    RTFWordExportFormatOptions RTFExpOpts = new RTFWordExportFormatOptions();

  2. Configure the options you wish to set.

    In this example, the export options are configured so that only pages 1 to 3 are exported.

    RTFExpOpts.setStartPageNumber(1);

    RTFExpOpts.setEndPageNumber(3);

  3. Call the ReportExportOptions object's setFormatOptions method, passing it the format options object.

    exportOptions.setFormatOptions(RTFExpOpts);

To initialize the Export Control
  1. Set the control's report source by calling its setReportSource method and passing the method a reference to the report source object that you created.

    exportControl.setReportSource(reportSource);

  2. Call the control's setExportOptions method, passing it the ExportOptions object that you created earlier.

    exportControl.setExportOptions(exportOptions);

  3. You may also want to call the setExportAsAttachment method.

    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/