PivotGridCsvExportOptions.CustomizeCell Event
Allows you to substitute a cell value in the output 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 PivotGridCsvExportOptions instance.
- Handle the PivotGridCsvExportOptions.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 PivotGridCsvExportOptions instance to the PivotGridControl.ExportToCsv(String, CsvExportOptions) method.
The following code snippet shows how to export data from a PivotGrid Control to CSV format. The PivotGridCsvExportOptions.CustomizeCell event is used to format the numbers in the exported cells as thousands.
//...
private void Options_CustomizeCell(CustomizePivotCellEventArgs e) {
if (e.ExportArea == PivotGridExportArea.Data && e.CellItemInfo.Value != null)
{
e.Value = string.Format("${0:0,}K", Convert.ToDecimal(e.CellItemInfo.Value));
e.Handled = true;
}
}
void Button_Click(object sender, RoutedEventArgs e) {
PivotGridCsvExportOptions op = new PivotGridCsvExportOptions();
op.Encoding = Encoding.Unicode;
op.Separator = CultureInfo.CurrentCulture.TextInfo.ListSeparator.ToString();
op.CustomizeCell += Options_CustomizeCell;
pivorGrid1.ExportToCsv(file, op);
}
See Also