Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

19.06 Exporting to Disk

Exporting to a Disk

Setting the destination type to disk is simple because there are only a couple properties. You have to instantiate a DiskFileDestinationOptions object and assign the filename to it. As you can see in Table 19-4, this is the only property available.

Table 19-4. DiskFileDestinationOptions Properties.

Property Description
DiskFileName The filename used for saving the report

The following code takes a report object and sets it to use a file as the destination.

Listing 19-2. Setting the destination to a disk file
Public Sub SetDiskFileDestination(ByRef MyReport As CrystalDecisions.CrystalReports.Engine.ReportDocument, ByVal FileName As String)
'Set the destination type to DiskFile
MyReport.ExportOptions.ExportDestinationType = _
CrystalDecisions.Shared.ExportDestinationType.DiskFile
'Instantiate a DiskFileDestinationOptions object and set the
'FileName property
Dim Options As CrystalDecisions.Shared.DiskFileDestinationOptions = _
New CrystalDecisions.Shared.DiskFileDestinationOptions
Options.DiskFileName = FileName
'Assign the object to the report
MyReport.ExportOptions.DestinationOptions = Options
End Sub

Pass this procedure a report object and a filename. It first sets the destination type to be DiskFile. Then it instantiates an options variable and sets its DiskFileName property to be the Filename string that was passed to the procedure. The last step assigns this destination object to the report object.