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

GridExportOptions Class

The base class for the GridXlExportOptions and GridCsvExportOptions classes. Contains common options that define how a document is exported.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v23.1.dll

NuGet Package: DevExpress.Blazor

Declaration

public abstract class GridExportOptions

Remarks

When you export grid data, the GridExportOptions class descendant object allows you to customize the settings of the exported data and the exported document.

<DxGrid @ref="Grid"
        Data="@Data"
        ShowSearchBox="true"
        SearchText="Manager"
        ShowGroupPanel="true"
        AutoExpandAllGroupRows="true"
        GroupFooterDisplayMode="GridGroupFooterDisplayMode.IfExpanded"
        SelectionMode="GridSelectionMode.Multiple"
        SelectAllCheckboxMode="GridSelectAllCheckboxMode.AllPages"
        SizeMode="Params.SizeMode" KeyboardNavigationEnabled="Params.KeyboardNavigationEnabled">
    <Columns>
        <DxGridSelectionColumn Width="60px" AllowSelectAll="true" />
        <DxGridDataColumn FieldName="ContactName" Width="15%" />
        <DxGridDataColumn FieldName="ContactTitle" Width="15%" />
        <DxGridDataColumn FieldName="CompanyName" Width="20%" />
        <DxGridDataColumn FieldName="Country" Width="15%" GroupIndex="0" />
        <DxGridDataColumn FieldName="FullAddress" UnboundType="GridUnboundColumnType.String" UnboundExpression="[City] + ' - ' + [PostalCode] + ' - ' + [Address]" />
    </Columns>
    <TotalSummary>
        <DxGridSummaryItem FieldName="ContactName" SummaryType="GridSummaryItemType.Count" />
    </TotalSummary>
    <GroupSummary>
        <DxGridSummaryItem FieldName="ContactName" SummaryType="GridSummaryItemType.Count" FooterColumnName="ContactName" />
    </GroupSummary>
</DxGrid>
@code {
    IEnumerable<object> Data { get; set; }
    IGrid Grid { get; set; }
    bool ExportSelectedRowsOnly { get; set; }

    protected override async Task OnInitializedAsync() {
        Data = await NwindDataService.GetCustomersAsync();
    }
    async Task ExportXlsx_Click() {
        await Grid.ExportToXlsxAsync("ExportResult", new GridXlExportOptions() {
            ExportSelectedRowsOnly = ExportSelectedRowsOnly,
            CustomizeCell = OnCustomizeCell
        });
    }
    async Task ExportXls_Click() {
        await Grid.ExportToXlsAsync("ExportResult", new GridXlExportOptions() {
            ExportSelectedRowsOnly = ExportSelectedRowsOnly,
            CustomizeCell = OnCustomizeCell
        });
    }
    void OnCustomizeCell (GridExportCustomizeCellEventArgs args) {
        if(args.ColumnFieldName == "ContactName" && args.AreaType == SheetAreaType.DataArea)
            args.Formatting.Font = new XlCellFont() { Italic = true };
        args.Handled = true;
    }
}

For more information about data export in the Grid component, refer to the following topic: Export Data in Blazor Grid.

Inheritance

See Also