Export in WPF OLAP Grid Control
2 Jun 20213 minutes to read
The OLAP grid data can be exported to Microsoft Excel, Microsoft Word, and PDF file formats. This can be achieved using the following methods of the OLAP grid.
Excel export
// Export OlapGrid Data to Excel
this.OlapGrid1.ExportToExcel("fileName");
' Export OlapGrid Data to Excel
Me.OlapGrid1.ExportToExcel("fileName")
Word export
// Export OlapGrid Data to Word
this.OlapGrid1.ExportToWord("fileName");
' Export OlapGrid Data to Word
Me.OlapGrid1.ExportToWord("fileName")
PDF export
// Export OlapGrid Data to PDF
this.OlapGrid1.ExportToPdf("fileName");
' Export OlapGrid Data to PDF
Me.OlapGrid1.ExportToPdf("fileName")
The format state of grid is maintained on exported documents.
Sample location
A sample demo is available in the following location.
..\Syncfusion\EssentialStudio<Versionnumber>\BI\WPF\OlapGrid.WPF\Samples\Exporting\Exporting Grid Demo
CSV export
The OLAP grid for WPF supports exporting itself to the CSV file format.
Methods
Method | Description | Parameters | Type | Return Type |
---|---|---|---|---|
Export(string filename) | Gets the file name to save the file with the specified name. | filename as string | - | void |
ExportToCsv(PivotEngine pivotEngine, string filename) | Gets the pivot engine and file name for exporting the content to a CSV file format with the specified name. | pivotEngine as PivotEngine, filename as string | - | void |
Adding CSV export for OLAP grid in an application
The GridCsvExport class supports for exporting data from OLAP grid to a CSV file format. Add the following assembly along with default assemblies in the reference folder:
- Syncfusion.OlapGridConverter.Wpf
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.AddExtension = true;
saveFileDialog.FileName = "OlapGrid Report";
saveFileDialog.DefaultExt = "CSV";
saveFileDialog.Filter = "Csv file (.csv)|*.csv";
if (saveFileDialog.ShowDialog() == true)
{
if (this.olapGrid.InternalGrid != null && this.olapGrid.InternalGrid.Engine != null)
{
GridCsvExport gridCsvExport = new GridCsvExport(this.olapGrid.InternalGrid.Engine);
gridCsvExport.Export(saveFileDialog.FileName);
MessageBox.Show("CSV document exported successfully!");
}
}
Dim saveFileDialog As New SaveFileDialog()
saveFileDialog.AddExtension = True
saveFileDialog.FileName = "OlapGrid Report"
saveFileDialog.DefaultExt = "CSV"
saveFileDialog.Filter = "Csv file (.csv)|*.csv"
If saveFileDialog.ShowDialog() = True Then
If Me.olapGrid.InternalGrid IsNot Nothing AndAlso Me.olapGrid.InternalGrid.Engine IsNot Nothing Then
Dim gridCsvExport As New GridCsvExport(Me.olapGrid.InternalGrid.Engine)
gridCsvExport.Export(saveFileDialog.FileName)
MessageBox.Show("CSV document exported successfully!")
End If
End If
Sample link
{Installation Drive}:\Users<user name>\AppData\Local\Syncfusion\EssentialStudio<version number>\BI\WPF\OlapGrid.Wpf\Samples\Exporting\Exporting Demo