Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

GridExportCustomizeCellEventArgs.GetRowValue(String) Method

Returns the value of a cell in the current row and in the specified data field.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
public object GetRowValue(
    string fieldName
)

#Parameters

Name Type Description
fieldName String

The field name.

#Returns

Type Description
Object

The cell value.

#Remarks

You can use the GetRowValue method in the following ways:

  • When data row is being processed (the AreaType property returns DataArea), call the GetRowValue method to get a value of the specified data field in the current row.
  • When a group row or group footer cell is being processed (the AreaType property returns the GroupHeader or GroupFooter value), use the GetRowValue method to get a value of the group field (returned by the GroupFieldName property).

The following code snippet highlights rows that have Total values more than 1000 or less than 100 in the exported file.

razor
<DxGrid @ref="Grid" Data="@Data" >
    <Columns>
        <DxGridDataColumn FieldName="CompanyName" />
        <DxGridDataColumn FieldName="City" />
        <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 {
    IGrid Grid { get; set; }
    // ...
    async Task ExportXlsx_Click() {
        var options = new GridXlExportOptions();
        options.CustomizeCell = (e) => {
            if (e.AreaType == DevExpress.Export.SheetAreaType.DataArea) {
                decimal total = (decimal)e.GetRowValue("Total");
                if (total > 1000) {
                    e.Formatting.BackColor = System.Drawing.Color.DarkSeaGreen;
                } else if (total < 100) {
                    e.Formatting.BackColor = System.Drawing.Color.DarkSalmon;
                };
                e.Handled = true;
            }
        };
        await Grid.ExportToXlsxAsync("ExportResult", options);
    }
}

Grid - Colored Rows

See Also