Skip to main content

GridCsvExportOptions Class

Contains options that define how the Grid exports its content in CSV format.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

Declaration

public class GridCsvExportOptions :
    GridExportOptions,
    IGridCsvExportOptions

Remarks

When you export the Grid’s data in CSV format (the ExportToCsvAsync method), the GridCsvExportOptions object allows you to customize the resulting document’s settings. Note that only data cell values are exported - group rows, summaries, and cell style settings are ignored.

Important

Security Considerations

Exported data can contain executable content. To prevent possible security vulnerabilities, set the EncodeExecutableContent property to true to enclose potentially dangerous content in quotation marks prior to exporting it to the CSV format. To learn more, see the property description.

<DxGrid @ref="Grid"
        Data="@Data"
        SelectionMode="GridSelectionMode.Multiple">
    <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%" />
        <DxGridDataColumn FieldName="FullAddress" UnboundType="GridUnboundColumnType.String" 
                          UnboundExpression="[City] + ' - ' + [PostalCode] + ' - ' + [Address]" />
    </Columns>
</DxGrid>
@* ... *@
<OptionButton Text="Export to CSV" OnClick="ExportCsv_Click" />
@* ... *@
@code {
    IEnumerable<object> Data { get; set; }
    IGrid Grid { get; set; }
    protected override async Task OnInitializedAsync() {
        Data = await NwindDataService.GetCustomersAsync();
    }
    async Task ExportCsv_Click() {
        await Grid.ExportToCsvAsync("ExportResult", new GridCsvExportOptions() {
            ExportSelectedRowsOnly = true,
        });
    }
}

Run Demo: Grid - Export

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

Inheritance

Object
DevExpress.Blazor.Internal.GridExportOptionsBase
GridExportOptions
GridCsvExportOptions
See Also