Back to Devexpress

MVCxPivotGridExportSettings.CustomExportCell Property

aspnetmvc-devexpress-dot-web-dot-mvc-dot-mvcxpivotgridexportsettings.md

latest5.9 KB
Original Source

MVCxPivotGridExportSettings.CustomExportCell Property

Enables you to specify a different content for individual cells, if the PivotGrid is exported in the WYSIWYG mode.

Namespace : DevExpress.Web.Mvc

Assembly : DevExpress.Web.Mvc5.v25.2.dll

NuGet Package : DevExpress.Web.Mvc5

Declaration

csharp
public EventHandler<WebCustomExportCellEventArgs> CustomExportCell { get; set; }
vb
Public Property CustomExportCell As EventHandler(Of WebCustomExportCellEventArgs)

Property Value

TypeDescription
EventHandler<WebCustomExportCellEventArgs>

A delegate method allowing you to implement custom processing.

|

Property Paths

You can access this nested property as listed below:

Object TypePath to CustomExportCell
PivotGridSettings

.SettingsExport .CustomExportCell

|

Remarks

The CustomExportCell event occurs for each cell when the PivotGrid is being exported in WYSIWYG mode, exported to PDF or printed. You can handle this event to change the cell’s appearance and contents in a printed document.

Note

The complete sample project How to obtain the appointment, resource or time interval selected by an end-user is available in the DevExpress Examples repository.

csharp
settings.SettingsExport.CustomExportCell = (sender, e) =>
{

    // Determine whether the cell is Grand Total.
    if ((e.ColumnField == null) || (e.RowField == null))
    {
        // Specify the text to display in a cell.
        ((DevExpress.XtraPrinting.TextBrick)e.Brick).Text = string.Format(
             "=> {0}",
             ((DevExpress.XtraPrinting.TextBrick)e.Brick).Text);
        // Specify the colors used to paint the cell.
        e.Appearance.BackColor = Color.Gray;
        e.Appearance.ForeColor = Color.Orange;
        return;
    }

    MVCxPivotGrid pivot = ((MVCxPivotGridExporter)sender).PivotGrid as MVCxPivotGrid;
    int lastRowFieldIndex = pivot.Fields.GetVisibleFieldCount(PivotArea.RowArea) - 1;
    int lastColumnFieldIndex = pivot.Fields.GetVisibleFieldCount(PivotArea.ColumnArea) - 1;

    // Determine whether the cell is an ordinary cell.
    if (e.RowField.AreaIndex == lastRowFieldIndex && e.ColumnField.AreaIndex == lastColumnFieldIndex)
    {
        e.Appearance.ForeColor = Color.Gray;
    }
    // The cell is a Total cell.
    else
    {
        e.Appearance.BackColor = Color.DarkOliveGreen;
        e.Appearance.ForeColor = Color.White;
    }
};
vb
settings_PivotGrid.SettingsExport.CustomExportCell =
    Sub(sender, e)

        ' Determine whether the cell is Grand Total.
        If (e.ColumnField Is Nothing) OrElse (e.RowField Is Nothing) Then
            ' Specify the text to display in a cell.
            CType(e.Brick, DevExpress.XtraPrinting.TextBrick).Text = String.Format("=> {0}", CType(e.Brick, DevExpress.XtraPrinting.TextBrick).Text)
            ' Specify the colors used to paint the cell.
            e.Appearance.BackColor = Color.Gray
            e.Appearance.ForeColor = Color.Orange
            Return
        End If

        Dim pivot As MVCxPivotGrid = TryCast(CType(sender, MVCxPivotGridExporter).PivotGrid, MVCxPivotGrid)
        Dim lastRowFieldIndex As Integer = pivot.Fields.GetVisibleFieldCount(PivotArea.RowArea) - 1
        Dim lastColumnFieldIndex As Integer = pivot.Fields.GetVisibleFieldCount(PivotArea.ColumnArea) - 1

        ' Determine whether the cell is an ordinary cell.
        If e.RowField.AreaIndex = lastRowFieldIndex AndAlso e.ColumnField.AreaIndex = lastColumnFieldIndex Then
            e.Appearance.ForeColor = Color.Gray
            ' The cell is a Total cell.
        Else
            e.Appearance.BackColor = Color.DarkOliveGreen
            e.Appearance.ForeColor = Color.White
        End If
    End Sub

Tip

The CustomExportCell and MVCxPivotGridExportSettings.CustomExportFieldValue events are not in effect during the export in Data-Aware mode. To customize cells in Data-Aware export mode, use the PivotXlsExportOptions.CustomizeCell and PivotXlsxExportOptions.CustomizeCell events.

See Also

Declaring Server-Side Event Handlers

CustomExportFieldValue

CustomExportHeader

Pivot Grid Export

MVCxPivotGridExportSettings Class

MVCxPivotGridExportSettings Members

DevExpress.Web.Mvc Namespace