This example shows how to export the pivot grid's data using the Data-Aware or WYSIWYG types and set the export options.
Click the Export to XLSX button to export data using the Data-Aware type. In the exported XLSX file, fixed row headers are disabled and a sheet name is set to "Pivot Grid Export".
Click the Export to PDF button to export data using the WYSIWYG type. The Print dialog is displayed when the exported PDF file is opened.
using System;
using DevExpress.XtraPrinting;
using DevExpress.Utils;
namespace ASPPivotGridExport
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void DataAwareExportButton_Click(object sender, EventArgs e)
{
// Exports using the Data-Aware type.
ASPxPivotGridExporter1.ExportXlsxToResponse("ASPxPivotGrid", new XlsxExportOptionsEx
{
AllowFixedColumns = DefaultBoolean.False,
SheetName = "Pivot Grid Export"
},
true);
}
protected void WysiwygExportButton_Click(object sender, EventArgs e)
{
// Exports using the WYSIWYG type.
ASPxPivotGridExporter1.ExportPdfToResponse("ASPxPivotGrid", new PdfExportOptions()
{
ShowPrintDialogOnOpen = true,
}, true);
}
}
}
Imports System
Imports DevExpress.XtraPrinting
Imports DevExpress.Utils
Namespace ASPPivotGridExport
Partial Public Class WebForm1
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Protected Sub DataAwareExportButton_Click(ByVal sender As Object, ByVal e As EventArgs)
' Exports using the Data-Aware type.
ASPxPivotGridExporter1.ExportXlsxToResponse("ASPxPivotGrid", New XlsxExportOptionsEx With
{.AllowFixedColumns = DefaultBoolean.False, .SheetName = "Pivot Grid Export"}, True)
End Sub
Protected Sub WysiwygExportButton_Click(ByVal sender As Object, ByVal e As EventArgs)
' Exports using the WYSIWYG type.
ASPxPivotGridExporter1.ExportPdfToResponse("ASPxPivotGrid", New PdfExportOptions() With
{.ShowPrintDialogOnOpen = True}, True)
End Sub
End Class
End Namespace