Share via


Creating Methods That Configure Multiple Export Formats

In this section, you create the private helper methods that configure the multiple export formats. All of these method are used similarly, except for ConfigureExportToHtml32() and ConfigureExportToHtml40(), which offer different ways to export to the HTML format.

  • ConfigureExportToRpt()
  • ConfigureExportToRtf()
  • ConfigureExportToDoc()
  • ConfigureExportToXls()
  • ConfigureExportToPdf()
  • ConfigureExportToHtml32()
  • ConfigureExportToHtml40()

To create the ConfigureExportToRpt() helper method

  1. Open the Web or Windows Form.

  2. From the View menu, click Code.

  3. At the bottom of the class, create a private helper method named ConfigureExportToRpt() with no return value.

``` vb
Public Sub ConfigureExportToRpt()

End Sub
```

``` csharp
private void ConfigureExportToRpt()
{
}
```
  1. Within the method, set the ExportFormatType property of the ExportOptions instance to the ExportFormatType enum selection CrystalReport.

    myExportOptions.ExportFormatType = ExportFormatType.CrystalReport
    
    exportOptions.ExportFormatType = ExportFormatType.CrystalReport;
    
  2. Set the DiskFileName property of the DiskFileDestinationOptions instance to the exportPath string, and then follow it with the name of a document that has an .rpt file extension.

    myDiskFileDestinationOptions.DiskFileName = exportPath &
    "Report.rpt"
    
    diskFileDestinationOptions.DiskFileName = exportPath +
    "Report.rpt";
    
  3. Finally, set the ExportDestinationOptions property of the ExportOptions instance to the DiskFileDestinationOptions instance that you have configured in the previous step.

    myExportOptions.ExportDestinationOptions = myDiskFileDestinationOptions
    
    exportOptions.ExportDestinationOptions = diskFileDestinationOptions;
    

To create the ConfigureExportToRtf helper method

  1. Open the Web or Windows Form.

  2. From the View menu, click Code.

  3. At the bottom of the class, create a private helper method named ConfigureExportToRtf() with no return value.

``` vb
Public Sub ConfigureExportToRtf()

End Sub
```

``` csharp
private void 
ConfigureExportToRtf()
{
}
```
  1. Within the method, set the ExportFormatType property of the ExportOptions instance to the ExportFormatType enum selection RichText.

    myExportOptions.ExportFormatType = ExportFormatType.RichText
    
    exportOptions.ExportFormatType = ExportFormatType.RichText;
    
  2. Set the DiskFileName property of the DiskFileDestinationOptions instance to the exportPath string, and then follow it with the name of a document that has an .rtf file extension.

    myDiskFileDestinationOptions.DiskFileName = exportPath & "RichTextFormat.rtf"
    
    diskFileDestinationOptions.DiskFileName = exportPath + "RichTextFormat.rtf";
    
  3. Finally, set the ExportDestinationOptions property of the ExportOptions instance to the DiskFileDestinationOptions instance that you have configured in the previous step.

    myExportOptions.ExportDestinationOptions = myDiskFileDestinationOptions
    
    exportOptions.ExportDestinationOptions = diskFileDestinationOptions;
    

To create the ConfigureExportToDoc helper method

  1. Open the Web or Windows Form.

  2. From the View menu, click Code.

  3. At the bottom of the class, create a private helper method named ConfigureExportToDoc() with no return value.

``` vb
Public Sub ConfigureExportToDoc()

End Sub
```

``` csharp
private void 
ConfigureExportToDoc()
{
}
```
  1. Within the method, set the ExportFormatType property of the ExportOptions instance to the ExportFormatType enum selection WordForWindows.

    myExportOptions.ExportFormatType = ExportFormatType.WordForWindows
    
    exportOptions.ExportFormatType = ExportFormatType.WordForWindows;
    
  2. Set the DiskFileName property of the DiskFileDestinationOptions instance to the exportPath string, and then follow it with the name of a document that has a .doc file extension.

    myDiskFileDestinationOptions.DiskFileName = exportPath &
    "Word.doc"
    
    diskFileDestinationOptions.DiskFileName = exportPath + "Word.doc";
    
  3. Finally, set the ExportDestinationOptions property of the ExportOptions instance to the DiskFileDestinationOptions instance that you have configured in the previous step.

    myExportOptions.ExportDestinationOptions = myDiskFileDestinationOptions
    
    exportOptions.ExportDestinationOptions = diskFileDestinationOptions;
    

To create the ConfigureExportToXls helper method

  1. Open the Web or Windows Form.

  2. From the View menu, click Code.

  3. At the bottom of the class, create a private helper method named ConfigureExportToXls() with no return value.

``` vb
Public Sub ConfigureExportToXls()

End Sub
```

``` csharp
private void 
ConfigureExportToXls()
{
}
```
  1. Within the method, set the ExportFormatType property of the ExportOptions instance to the ExportFormatType enum selection Excel.

    myExportOptions.ExportFormatType = ExportFormatType.Excel
    
    exportOptions.ExportFormatType = ExportFormatType.Excel;
    
  2. Set the DiskFileName property of the DiskFileDestinationOptions instance to the exportPath string, and then follow it with the name of a document that has an .xls file extension.

    myDiskFileDestinationOptions.DiskFileName = exportPath & "Excel.xls"
    
    diskFileDestinationOptions.DiskFileName = exportPath + "Excel.xls";
    
  3. Finally, set the ExportDestinationOptions property of the ExportOptions instance to the DiskFileDestinationOptions instance that you have configured in the previous step.

    myExportOptions.ExportDestinationOptions = myDiskFileDestinationOptions
    
    exportOptions.ExportDestinationOptions = diskFileDestinationOptions;
    

To create the ConfigureExportToPdf helper method

  1. Open the Web or Windows Form.

  2. From the View menu, click Code.

  3. At the bottom of the class, create a private helper method named ConfigureExportToPdf() with no return value.

``` vb
Public Sub ConfigureExportToPdf()

End Sub
```

``` csharp
private void 
ConfigureExportToPdf()
{
}
```
  1. Within the method, set the ExportFormatType property of the ExportOptions instance to the ExportFormatType enum selection PortableDocFormat.

    myExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat
    
    exportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
    
  2. Set the DiskFileName property of the DiskFileDestinationOptions instance to the exportPath string, and then follow it with the name of a document that has a .pdf file extension.

    myDiskFileDestinationOptions.DiskFileName = exportPath & "PortableDoc.pdf"
    
    diskFileDestinationOptions.DiskFileName = exportPath + "PortableDoc.pdf";
    
  3. Finally, set the ExportDestinationOptions property of the ExportOptions instance to the DiskFileDestinationOptions instance that you have configured in the previous step.

    myExportOptions.ExportDestinationOptions = myDiskFileDestinationOptions
    
    exportOptions.ExportDestinationOptions = diskFileDestinationOptions;
    

To create the ConfigureExportToHtml32 helper method

  1. Open the Web or Windows Form.

  2. From the View menu, click Code.

  3. At the bottom of the class, create a private helper method named ConfigureExportToHtml32() with no return value.

``` vb
Public Sub ConfigureExportToHtml32()

End Sub
```

``` csharp
private void 
ConfigureExportToHtml32()
{
}
```
  1. Within the method, set the ExportFormatType property of the ExportOptions instance to the ExportFormatType enum selection HTML32.

    myExportOptions.ExportFormatType = ExportFormatType.HTML32
    
    exportOptions.ExportFormatType = ExportFormatType.HTML32;
    
  2. Declare and instantiate the HTMLFormatOptions class with the variable name "html32FormatOptions."

    Dim html32FormatOptions As HTMLFormatOptions = New
    HTMLFormatOptions()
    
    HTMLFormatOptions html32FormatOptions = new HTMLFormatOptions();
    
  3. Set the HTMLBaseFolderName property of the html32FormatOptions instance to the exportPath string, and the name "Html32Folder."

    html32FormatOptions.HTMLBaseFolderName = exportPath &
    "Html32Folder"
    
    html32FormatOptions.HTMLBaseFolderName = exportPath +
    "Html32Folder";
    
  4. Set the HTMLFileName property of the html32FormatOptions instance to the name "html32.html."

    html32FormatOptions.HTMLFileName = "html32.html"
    
    html32FormatOptions.HTMLFileName = "html32.html";
    
  5. Set the HTMLEnableSeparatedPage property of the html32FormatOptions instance to be "False."

    html32FormatOptions.HTMLEnableSeparatedPages = False
    
    html32FormatOptions.HTMLEnableSeparatedPages = false;
    
  6. Set the HTMLHasPageNavigator property of the html32FormatOptions instance to be "False."

    html32FormatOptions.HTMLHasPageNavigator = False
    
    html32FormatOptions.HTMLHasPageNavigator = false;
    
  7. Finally, assign the html32FormatOptions instance to the FormatOptions property of the ExportOptions instance.

    myExportOptions.ExportFormatOptions = html32FormatOptions
    
    exportOptions.ExportFormatOptions = html32FormatOptions;
    

To create the ConfigureExportToHtml40 helper method

  1. Open the Web or Windows Form.

  2. From the View menu, click Code.

  3. At the bottom of the class, create a private helper method named ConfigureExportToHtml40() with no return value.

``` vb
Public Sub ConfigureExportToHtml40()

End Sub
```

``` csharp
private void 
ConfigureExportToHtml40()
{
}
```
  1. Within the method, set the ExportFormatType property of the ExportOptions instance to the ExportFormatType enum selection HTML40.

    myExportOptions.ExportFormatType = ExportFormatType.HTML40
    
    exportOptions.ExportFormatType = ExportFormatType.HTML40;
    
  2. Declare and instantiate the HTMLFormatOptions class with the variable name "html40FormatOptions."

    Dim html40FormatOptions As HTMLFormatOptions = New
    HTMLFormatOptions()
    
    HTMLFormatOptions html40FormatOptions = new HTMLFormatOptions();
    
  3. Set the HTMLBaseFolderName property of the html40FormatOptions instance to the exportPath string and the name "Html40Folder."

    html40FormatOptions.HTMLBaseFolderName = exportPath &
    "Html40Folder"
    
    html40FormatOptions.HTMLBaseFolderName = exportPath +
    "Html40Folder";
    
  4. Set the HTMLFileName property of the html40FormatOptions instance to the name "html40.html."

    html40FormatOptions.HTMLFileName = "html40.html"
    
    html40FormatOptions.HTMLFileName = "html40.html";
    
  5. Set the HTMLEnableSeparatedPage property of the html40FormatOptions instance to "True."

    html40FormatOptions.HTMLEnableSeparatedPages = True
    
    html40FormatOptions.HTMLEnableSeparatedPages = true;
    
  6. Set the HTMLHasPageNavigator property of the html40FormatOptions instance to be "True."

    html40FormatOptions.HTMLHasPageNavigator = True
    
    html40FormatOptions.HTMLHasPageNavigator = true;
    
  7. Set the FirstPageNumber property of the html40FormatOptions instance to 1.

    html40FormatOptions.FirstPageNumber = 1
    
    html40FormatOptions.FirstPageNumber = 1;
    
  8. Set the LastPageNumber property of the html40FormatOptions instance 3.

    html40FormatOptions.LastPageNumber = 3
    
    html40FormatOptions.LastPageNumber = 3;
    
  9. Finally, assign the html40FormatOptions instance to the FormatOptions property of the ExportOptions instance.

    myExportOptions.FormatOptions = html40FormatOptions
    
    exportOptions.FormatOptions = html40FormatOptions;
    

You have created the private helper methods that configure the multiple export formats.