Skip to main content
All docs
V25.1
  • GridExportCustomizeCellEventArgs.ColumnFieldName Property

    Returns the name of the data source field bound to the column that contains the processed cell.

    Namespace: DevExpress.Blazor

    Assembly: DevExpress.Blazor.v25.1.dll

    NuGet Package: DevExpress.Blazor

    Declaration

    public string ColumnFieldName { get; set; }

    Property Value

    Type Description
    String

    The field name.

    Remarks

    The CustomizeCell action allows you to customize a cell in the exported file. Use the ColumnFieldName property to determine the column that contains the processed cell.

    <DxGrid @ref="Grid" Data="@Data" >
        <Columns>
            <DxGridDataColumn FieldName="OrderDate" />
            <DxGridDataColumn FieldName="CompanyName"  />
            <DxGridDataColumn FieldName="Country" />
            <DxGridDataColumn FieldName="UnitPrice" DisplayFormat="c" />
            <DxGridDataColumn FieldName="Quantity" />
            <DxGridDataColumn FieldName="Total" UnboundType="GridUnboundColumnType.Decimal" 
                              DisplayFormat="c" UnboundExpression="[UnitPrice]*[Quantity]" />
        </Columns>
    </DxGrid>
    <DxButton Text="Export to XLSX" Click="ExportXlsx_Click" />
    @code {
        object Data { get; set; }
        IGrid Grid { get; set; }
        IEnumerable<GridGroupFooterDisplayMode> DisplayModes { get; } = Enum.GetValues(typeof(GridGroupFooterDisplayMode)).Cast<GridGroupFooterDisplayMode>();
        GridGroupFooterDisplayMode CurrentDisplayMode { get; set; } = GridGroupFooterDisplayMode.Auto;
        protected override async Task OnInitializedAsync() {
            var invoices = await NwindDataService.GetInvoicesAsync();
            var customers = await NwindDataService.GetCustomersAsync();
            Data = invoices.OrderBy(i => i.OrderDate).Join(customers, i => i.CustomerId, c => c.CustomerId, (i, c) => {
                return new {
                    OrderDate = i.OrderDate,
                    CompanyName = c.CompanyName,
                    City = i.City,
                    Region = i.Region,
                    Country = i.Country,
                    UnitPrice = i.UnitPrice,
                    Quantity = i.Quantity
                };
            });
        }
        async Task ExportXlsx_Click() {
            var options = new GridXlExportOptions();
            options.CustomizeCell = e => {
                // Highlight data cells where Total > 1000 
                if (e.AreaType == DevExpress.Export.SheetAreaType.DataArea && e.ColumnFieldName == "Total" && (decimal)e.Value > 1000) {
                    e.Formatting.BackColor = System.Drawing.Color.LightGreen;
                    e.Handled = true;
                }
            };
           await Grid.ExportToXlsxAsync("ExportResult", options);
        }
    }
    

    Grid - Formatted Cells

    Run Demo: Grid - Export Data

    See Also