Skip to main content
All docs
V25.1
  • DevExpress v25.1 Update — Your Feedback Matters

    Our What's New in v25.1 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

    GridCsvExportOptions Class

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

    Namespace: DevExpress.Blazor

    Assembly: DevExpress.Blazor.v25.1.dll

    NuGet Package: DevExpress.Blazor

    #Declaration

    C#
    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.

    Razor
    <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 Blazor Grid Data to CSV.

    #Inheritance

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