Exporting reports

This lesson demonstrates how to export the Crystal report to different formats. The export formats available for the JRC are: Portable Document Format (PDF), Rich Text Format (RTF), Editable RTF, Comma Separated Value (CSV), and Crystal Reports Format. For the purpose of this tutorial, RTF has been chosen as the export format.

To export a Crystal Reports report
  1. In the Project Explorer view, go to CrystalReportsDemo\WebContent. Right-click WebContent and click New > JSP.
  2. The New JavaServer Page dialog box opens.

  3. In the File name field, type ExportReport.jsp.
  4. Click Finish.
  5. Double-click ExportReport.jsp to open the document.
  6. Enter the code snippet:
  7. <%@page import="com.crystaldecisions.reports.sdk.*" %>

    <%@page import="com.crystaldecisions.sdk.occa.report.reportsource.*" %>

    <%@page import="com.crystaldecisions.sdk.occa.report.lib.*" %>

    <%@page import="com.crystaldecisions.sdk.occa.report.exportoptions.*" %>

    <%@page import="com.crystaldecisions.report.web.viewer.*"%>

    <%

    ReportClientDocument reportClientDoc = new ReportClientDocument();

    String report = "/Sample Reports/Customer Profile Report.rpt";

    reportClientDoc.open(report, 0);

    Object reportSource = reportClientDoc.getReportSource();        

    ReportExportControl exportControl = new ReportExportControl();

    ExportOptions exportOptions = new ExportOptions();

    exportOptions.setExportFormatType(ReportExportFormat.RTF);

    RTFWordExportFormatOptions RTFExpOpts = new RTFWordExportFormatOptions();

    RTFExpOpts.setStartPageNumber(1);

    RTFExpOpts.setEndPageNumber(3);

    exportOptions.setFormatOptions(RTFExpOpts);    

    exportControl.setReportSource(reportSource);

    exportControl.setExportOptions(exportOptions);

    exportControl.setExportAsAttachment(true);

    exportControl.processHttpRequest(request, response, getServletConfig().getServletContext(), out);

    %>

    Note:    This code snippet will export the Customer Profile Report.rpt to RTF.

  8. Right-click ExportReport.jsp and click Run As > Run on Server.
  9. Click Finish.
  10. A Crystal Reports Viewer DHTML report page launches.

  11. When prompted, open the exported Crystal report.





Business Objects
http://www.businessobjects.com/
Support services
http://www.businessobjects.com/services/support/