Version

Export(OutputFormat,Stream) Method

Exports the Report in a specified file format in a specified stream.
Syntax
'Declaration
 
Public Overloads Sub Export( _
   ByVal outputFormat As OutputFormat, _
   ByVal stream As Stream _
) 
public void Export( 
   OutputFormat outputFormat,
   Stream stream
)

Parameters

outputFormat
The output document type (XPS only).
stream
The stream to which the Report will be exported.
Exceptions
ExceptionDescription
System.NotSupportedExceptionThe exception will be thrown if you try to run export in a non FullTrust environment.
System.InvalidOperationExceptionThe exception will be thrown if you try to export or print a Report that doesn't have any sections.
Remarks

If you stream is null then the result will be the same as calling Export(OutputFormat).

Example
This sample shows hot to export report to XPS file. When you create stream you have to close it after export.

Private Sub ExportReport()
    Dim reportObj As New Report()
    Dim section As New EmbeddedVisualReportSection(XamDataGrid1)
    reportObj.Sections.Add(section)
    
    ' Create stream and call export method
    Using fs As New FileStream("C:\export.xps", FileMode.Create)
        reportObj.Export(OutputFormat.XPS, fs)
    End Using
End Sub
private void ExportReport()
{
	Report reportObj = new Report();
	EmbeddedVisualReportSection section = new EmbeddedVisualReportSection(XamDataGrid1);
	reportObj.Sections.Add(section);

	// Create stream and call export method
   using (FileStream fs = new FileStream("C:\\export.xps", FileMode.Create))
   {
      reportObj.Export(OutputFormat.XPS, fs);
   }
}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also