Using the Export Control to Deliver Reports in Other Formats


So far all the scenarios that have been discussed in this chapter have involved displaying reports in dynamic HTML format. Although this is a great report delivery method for most scenarios, there are times when reports need to be exported to various other file formats. Although this can be accomplished by using the ReportClientDocument object model, there is an easier way to do this: using the Export control.

Listing 33.10 shows how the Export control would be used to export a report to PDF. Notice that the Export control has the concept of the report source of the processHttpRequest method.

Listing 33.10. Exporting a Report via Code

//Instantiate a ReportExportControl object ReportExportControl exportControl = new ReportExportControl(); //After you have created the ReportExportControl object, you must specify the //export format that you want to export the report to. To specify the export //format create an ExportOptions object: ExportOptions exportOptions = new ExportOptions(); //Specify the export format by calling the ExportOptions object's setExportFormatType method, passing it the integer constant that //represents the chosen format: exportOptions.setExportFormatType(ReportExportFormat.PDF); //To initialize an Export control in a BusinessObjects Enterprise environment set //the control's report source by calling its setReportSource method. exportControl.setReportSource(reportSource); //Call the control's setExportOptions method, passing it an __ ExportOptions object exportControl.setExportOptions(exportOptions); //You may also want to call the setExportAsAttachment method, passing it the //Boolean value true. The Export control will then display a dialog box //that allows users of your web application to save the exported report before //they open it: exportControl.setExportAsAttachment(true); //To initialize an Export control in an unmanaged RAS environment set the //control's report source by calling its setReportSource method and passing //the method a reference to a report source object. exportControl.setReportSource(reportSource); //Call the control's setExportOptions method, passing it an ExportOptions object exportControl.setExportOptions(exportOptions); //You may also want to call the setExportAsAttachment method, passing it the //Boolean value true. The Export control will then display a dialog box //that allows users of your web application to save the exported report before //they open it: exportControl.setExportAsAttachment(true); //After you have created an export control, you call its processHttpRequest //method to complete the export. exportControl.processHttpRequest(request, response, getServletContext(), null) ;

Figure 33.4 shows a report being exported to PDF.

Figure 33.4. Using the Export control to export a report to PDF.





Crystal Reports XI(c) Official Guide
Crystal Reports XI Official Guide
ISBN: 0672329174
EAN: 2147483647
Year: N/A
Pages: 365

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net