Example 1 - Export a Report

The following example is a simple JSP page that demonstrates how to use the export control to export the first three pages of a report to RTF.

Note:    The report used in this example is not included with the tutorials.

exportreport.jsp

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

<%@ page import="com.crystaldecisions.reports.sdk.ReportClientDocument" %>

<%@ 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" %>

<%

    Object reportSource = session.getAttribute("reportSource");

    if (reportSource == null)

    {

       String report = "/reports/sample.rpt";

       ReportClientDocument reportClientDoc = new ReportClientDocument();

       reportClientDoc.open(report, 0);

       reportSource = reportClientDoc.getReportSource();

       session.setAttribute("reportSource", reportSource);

    }

    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(), null);

%>



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