Skip to main content

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.v23.2.dll

NuGet Package: DevExpress.Wpf.PivotGrid

Declaration

public event CustomizePivotCellEventHandler CustomizeCell

Remarks

Follow the steps below to customize data in the output document.

  1. Create the PivotGridCsvExportOptions instance.
  2. Handle the PivotGridCsvExportOptions.CustomizeCell event.
  3. Use the CustomizePivotCellEventArgs.Formatting property to specify the cell’s appearance settings.
  4. Use the CustomizePivotCellEventArgs.ValueItemInfo property to specify the field to which the customized cell belongs.
  5. To export cells with custom formatting, set the Handled parameter to true.
  6. 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