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.
The New JavaServer Page dialog box opens.
ExportReport.jsp.<%@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.
A Crystal Reports Viewer DHTML report page launches.
| Business Objects http://www.businessobjects.com/ Support services http://www.businessobjects.com/services/support/ |