Version

Export(OutputFormat,String,Boolean) Method

Exports the Report to a file in the specified file format using the specified file name.
Syntax
'Declaration
 
Public Overloads Sub Export( _
   ByVal outputFormat As OutputFormat, _
   ByVal fileName As String, _
   ByVal showSaveFileDialog As Boolean _
) 
public void Export( 
   OutputFormat outputFormat,
   string fileName,
   bool showSaveFileDialog
)

Parameters

outputFormat
The output document type (XPS only).
fileName
The file name where the report will be exported. If the file exists, it will be overwritten.
showSaveFileDialog
If true the SaveFileDialog will be shown.
Exceptions
ExceptionDescription
System.ArgumentExceptionThe exception can be thrown if the file name is invalid or the directory doesn't exists
System.NotSupportedExceptionThe exception will be thrown if you try to run export in 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 showSaveFileDialog is true then the filename parameter will be used as the default file name in the SaveFileDialog. Otherwise, if the fileName is null or an empty string then the Report will be exported in System.Environment.CurrentDirectory with default file name: Export.xps. If the fileNam contains only a folder name, e.g. 'C:\MyFolder\', the Report will be exported in that folder with a filename of Export.xps. If the parameter only contains a file name, e.g. "xamGridExport.xps", the Report will be exported in the CurrentDirectory with the specified name.

Example
This example shows how to export report to XPS file

Private  Sub ExportReport()
   Dim reportObj As Report =  New Report() 
   Dim section As EmbeddedVisualReportSection =  New EmbeddedVisualReportSection(XamDataGrid1) 
   reportObj.Sections.Add(section)
 
   ' Call export method and put to it file to export without SaveFileDialog
   reportObj.Export(OutputFormat.XPS, "C:\\export.xps", False)
End Sub
private void ExportReport()
{
   Report reportObj = new Report();
   EmbeddedVisualReportSection section = new EmbeddedVisualReportSection(XamDataGrid1);
   reportObj.Sections.Add(section);

   // Call export method and put to it file to export without SaveFileDialog
   reportObj.Export(OutputFormat.XPS, "C:\\export.xps", false);
}
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