Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

19.04 Easy Exporting to Disk

Easy Exporting To Disk

There is one method that makes exporting easy: ExportToDisk(). Without a doubt, the ExportToDisk() method is the most popular way of exporting a report because you are only required to specify the format type and the filename. The following code shows an example saving a report as a PDF file. You can see that only one line of code is required to export the report to a PDF formatted file.

ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, _
"C:\Report.PDF")

The drawback to using the ExportToDisk() method is that it doesn’t have any parameters for customizing the export format. For example, there is no way to specify the page range. To customize the report format that gets exported, you have to use the more advanced Export() method. Table 19-2 shows the enumerations used with the ExportToDisk() method. Each of these enumeration constants listed in the table is within the namespace CrystalDecisions.Shared.ExportFormatType.

Table 19-2. Enumeration constants for the export format.

Format File Extension Enumeration Constant
Adobe Acrobat .PDF PortableDocFormat
Rich Text Format .RTF RichText
HTML 3.2 .HTM / .HTML HTML32
HTML 4.0 .HTM / .HTML HTML40
MS Word .DOC WordForWindows
MS Excel .XLS Excel