Version

Export(OutputFormat,String) 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 _
) 
public void Export( 
   OutputFormat outputFormat,
   string fileName
)

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.
Exceptions
ExceptionDescription
System.NotSupportedExceptionThe exception will be thrown if you try to run export in non FullTrust environment.
Remarks

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 CreateExport()
	Dim saveDlg As SaveFileDialog =  New SaveFileDialog() 
	saveDlg.Filter = "XPS documents|*.xps"
	If Not saveDlg.ShowDialog().GetValueOrDefault() Then
		Return
	End If
 
	' 1. Create Report object
	Dim reportObj As Report =  New Report() 
 
	' 2. Create EmbeddedVisualReportSection section. 
	' Put the grid you want to print as a parameter of section's constructor
	Dim section As EmbeddedVisualReportSection =  New EmbeddedVisualReportSection(XamDataGrid1) 
 
	' 3. Add created section to report's section collection
	reportObj.Sections.Add(section)
 
	' Optional. If you have progress indicator set its Report property to created report
	progressInfo.Report = reportObj
 
	' 4. Call export method
	reportObj.Export(OutputFormat.XPS, saveDlg.FileName)
 
End Sub
private void CreateExport()
{
	SaveFileDialog saveDlg = new SaveFileDialog();
	saveDlg.Filter = "XPS documents|*.xps";
	if (!saveDlg.ShowDialog().GetValueOrDefault())
		return;

	// 1. Create Report object
	Report reportObj = new Report();
	
	// 2. Create EmbeddedVisualReportSection section. 
	// Put the grid you want to print as a parameter of section's constructor
	EmbeddedVisualReportSection section = new EmbeddedVisualReportSection(XamDataGrid1);
	
	// 3. Add created section to report's section collection
	reportObj.Sections.Add(section);

	// Optional. If you have progress indicator set its Report property to created report
	progressInfo.Report = reportObj;
	
	// 4. Call export method
	reportObj.Export(OutputFormat.XPS, saveDlg.FileName);

}
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