Share via


Using the ExportToStream() Method

In this section, you learn how to use the ExportToStream() method to export the report to the input/output stream as a sequence of bytes. Then, you learn how to write the sequence of bytes to a file of your specified format.

When you export the report to the HTML formats, the images are not exported. It is recommended to use the ExportToHttpResponse() methods when you want to export to the HTML formats.

Prerequisites:

To modify the case statements in the ExportSelection() method

  1. Within the ExportSelection() method, declare a string variable and instantiate the variable to an empty string.
``` vb
Dim myFileName As String = ""
```

``` csharp
string fileName = "";
```
  1. Within the ExportFormatType.CrystalReport case statement, set the file name string to the exportPath string that is followed by a recognizable document name with a .rpt file extension.

    myFileName = exportPath & "Report.rpt"
    
    myFileName = exportPath + "Report.rpt";
    
  2. Within the ExportFormatType.RichText case statement, set the file name string to the exportPath string that is followed by a recognizable document name with a .rtf file extension.

    myFileName = exportPath & "RichTextFormat.rtf"
    
    myFileName = exportPath + "RichTextFormat.rtf";
    
  3. Within the ExportFormatType.WordForWindows case statement, set the file name string to the exportPath string that is followed by a recognizable document name with a .doc file extension.

    myFileName = exportPath & "Word.doc"
    
    fileName = exportPath + "Word.doc";
    
  4. Within the ExportFormatType.Excel case statement, set the file name string to the exportPath string that is followed by a recognizable document name with a .xls file extension.

    myFileName = exportPath & "Excel.xls"
    
    fileName = exportPath + "Excel.xls";
    
  5. Within the ExportFormatType.PortableDocFormat case statement, set the file name string to the exportPath string that is followed by a recognizable document name with a .pdf file extension.

    myFileName = exportPath & "PortableDoc.pdf"
    
    fileName = exportPath + "PortableDoc.pdf";
    
  6. Within the ExportFormatType.HTML32 case statement, set the file name string to the exportPath string that is followed by a recognizable document name with a .html file extension.

    myFileName = exportPath & "HTML32.html"
    
    fileName = exportPath + "HTML32.html";
    
  7. Within the ExportFormatType.HTML40 case statement, set the file name string to the exportPath string that is followed by a recognizable document name with a .html file extension.

    myFileName = exportPath & "HTML40.html"
    
    fileName = exportPath + "HTML40.html";
    
  8. Within the ExportFormatType.ExcelRecord case statement, set the file name string to the exportPath string that is followed by a recognizable document name with a .xls file extension.

    myFileName = exportPath & "ExcelRecord.xls"
    
    fileName = exportPath + "ExcelRecord.xls";
    

In this section: