本課程將示範如何將 Crystal 報表匯出至不同的格式。JRC 可以使用的匯出格式有:可攜式文件格式 (Portable Document Format,PDF)、Rich Text 格式 (RTF)、可編輯的 RTF、逗號分隔值 (CSV) 及 Crystal Reports 格式。針對本教學課程的目的,選擇 RTF 作為匯出格式。
[新增 JavaServer 頁面] 對話方塊便會開啟。
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);
%>
注意:
此程式碼片段將匯出 Customer Profile Report.rpt 至 RTF。
Crystal Reports 檢視器 DHTML 報表頁面便會啟動。
| Business Objects http://www.taiwan.businessobjects.com/ 支援服務 http://www.businessobjects.com/services/support/ |