Skip to main content
A newer version of this page is available. .

PivotXlsxExportOptions.CustomizeCell Event

Allows you to specify cell formatting when exporting a Pivot Grid control to XLSX format in data-aware mode.

Namespace: DevExpress.Web.ASPxPivotGrid

Assembly: DevExpress.Web.ASPxPivotGrid.v19.2.dll

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 that you should set the CustomizePivotCellEventArgs.Handled parameter to true to apply changes.

Note

The complete sample project How to Export ASP.NET MVC Pivot Grid to PDF and XLSX Formats with Custom Settings is available in the DevExpress Examples repository.

PivotXlsxExportOptions GetXlsxOptions()
    {
        PivotXlsxExportOptions options = new PivotXlsxExportOptions();
        options.CustomizeCell += Options_CustomizeCell;
        return options;
    }
void Options_CustomizeCell(CustomizePivotCellEventArgs e)
    {
        if (e.CellItemInfo != null)
        {
            switch (e.CellItemInfo.ColumnValueType)
            {
                case PivotGridValueType.GrandTotal:
                    // Specify the text to display in a cell.
                    e.Value = string.Format("=> {0}", e.Value.ToString());
                    // Specify the colors used to paint the cell.
                    e.Formatting.BackColor = Color.Gray;
                    e.Formatting.Font.Color = Color.Orange;
                    break;
                case PivotGridValueType.Total:
                    e.Formatting.BackColor = Color.DarkOliveGreen;
                    e.Formatting.Font.Color = Color.White;
                    break;
                case PivotGridValueType.Value:
                    e.Formatting.Font.Color = Color.Gray;
                    break;
            }
            e.Handled = true;
        }
    }

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomizeCell event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also