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. Reference the required Java classes and packages.
  2. <%@ 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" %>

  3. Create a ReportExportControl object.
  4. 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.

To specify the export format
  1. Create an ExportOptions object.
  2. ExportOptions exportOptions = new ExportOptions();

  3. Specify the export format by calling the setExportFormatType method, passing it a ReportExportFormat constant representing the desired format.
  4. 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.

To configure format specific options
  1. Create the appropriate format options object.
  2. In this case, a RTFWordExportFormatOptions object is created because the export format is RTF.

    RTFWordExportFormatOptions RTFExpOpts = new RTFWordExportFormatOptions();

  3. Configure the options you want to set.
  4. In this example, the export options are configured so that only pages 1 to 3 are exported.

    RTFExpOpts.setStartPageNumber(1);

        RTFExpOpts.setEndPageNumber(3);

  5. Call the ReportExportOptions object's setFormatOptions method, passing it the format options object.
  6. 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.
  2. exportControl.setReportSource(reportSource);

  3. Call the setExportOptions method, passing it the ExportOptions object that you created earlier.
  4. exportControl.setExportOptions(exportOptions);

  5. You may also want to call the setExportAsAttachment method.
  6. 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/