PivotGridXlsxExportOptions.CustomizeCell Event
Allows you to customize a PivotGrid’s cell in the exported XLSX document. Only available in data-aware export mode.
Namespace: DevExpress.Xpf.PivotGrid
Assembly: DevExpress.Xpf.PivotGrid.v24.2.dll
NuGet Package: DevExpress.Wpf.PivotGrid
Declaration
Remarks
Follow the steps below to customize data in the output document.
- Create the PivotGridXlsxExportOptions instance.
- Handle the PivotGridXlsxExportOptions.CustomizeCell event.
- Use the CustomizePivotCellEventArgs.Formatting property to specify the cell’s appearance settings.
- Use the CustomizePivotCellEventArgs.ValueItemInfo property to specify the field to which the customized cell belongs.
- To export cells with custom formatting, set the Handled parameter to true.
- To export customized data from a PivotGrid Control, pass the PivotGridXlsxExportOptions instance to the ExportToXlsx method.
The following example exports data from a PivotGrid Control to Xlsx format. The PivotGridXlsxExportOptions.CustomizeCell event is used to change the background color of the “Category Name” column in the output document.
//...
void op_CustomizeCell(CustomizePivotCellEventArgs e){
if (e.ValueItemInfo != null && e.ValueItemInfo.Field == fieldCategoryName)
{
e.Formatting.BackColor = Color.AliceBlue;
e.Handled = true;
}
}
void Button_Click(object sender, RoutedEventArgs e) {
PivotGridXlsxExportOptions op = new PivotGridXlsxExportOptions();
op.CustomizeCell += op_CustomizeCell;
pivorGrid1.ExportToXlsx(file, op);
}
See Also