Advanced Exporting
When you want to do more than a simple export to disk, use the Export() method. It has many classes and properties for customizing the export process. Consequently, having additional classes and properties makes this method more complicated to learn and use. This chapter gives you many examples that make it easy to copy and paste the code listings into your application.
Exporting a report consists of the following steps:
Create an ExportOptions object and set its properties.
Assign the type of destination where the export should be sent (e.g. disk file, email, MS Exchange Server).
Set the format type (Excel, PDF, etc.).
Assign the formatting options specific to each format type.
Call the ReportDocument.Export() method and pass it the ExportOptions object.
Although these steps are the same for every type of export, their implementation varies. Within the code listings of the following sections, you will see the details of how to perform each step. However, one aspect that is common to them all is they all use the ExportDestinationType enumeration. This specificies the destination for the export. This could be a disk file, an email, or a MS Exchange Server folder. You have to specify the destination type so that Crystal Reports knows where to send the export. Table 19-3 shows the values for the CrystalDecisions.Shared.ExportDestinationType enumeration.
Table 19-3. Enumeration constants for ExportDestinationType.
Destination | Enumeration Constant |
---|---|
Disk File | DiskFile |
Exchange Folder | ExchangeFolder |
Email (MAPI) | MicrosoftMail |
The following sections show you how to perform each type of export available in Crystal Reports. They cover exporting to PDF, RTF, Word, Excel, HTML, email, and MS Exchange Server.