Skip to main content

PivotXlsExportOptions.CustomizeCell Event

Allows you to customize a PivotGrid’s cell in the exported XLS document.

Namespace: DevExpress.XtraPivotGrid

Assembly: DevExpress.XtraPivotGrid.v24.1.dll

NuGet Package: DevExpress.Win.PivotGrid

Declaration

public event CustomizePivotCellEventHandler CustomizeCell

Remarks

Use the CustomizePivotCellEventArgs.RowType and CustomizePivotCellEventArgs.ColumnType parameters to identify a row and column containing the cell. To specify the cell location in the exported Excel document, use the CustomizePivotCellEventArgs.ExportArea property. To customize the cell format, use the CustomizePivotCellEventArgs.Formatting property.

Note

Set the CustomizePivotCellEventArgs.Handled parameter to true to export cells with custom formatting.

The following example exports data from a PivotGrid Control to Xls format. The PivotXlsExportOptions.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;
    }
}

private void button1_Click(object sender, EventArgs e){
    PivotXlsExportOptions op = new PivotXlsExportOptions();
    op.CustomizeCell += op_CustomizeCell;
    pivotGridControl1.ExportToXls(fileName, op);
}

Note

To customize a PivotGrid’s cell during the export in WYSIWYG mode, use the PivotGridControl.CustomExportFieldValue and PivotGridControl.CustomExportCell events.

More Examples

View Example: Customize Cells in the Exported Excel Document

See Also