Skip to main content

GridCsvExportOptions.Encoding Property

Specifies the encoding of the exported CSV file.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v23.2.dll

NuGet Package: DevExpress.Blazor

Declaration

public Encoding Encoding { get; set; }

Property Value

Type Description
Encoding

The file encoding.

Remarks

Use the Encoding property to specify the encoding of the exported CSV file.

The following example sets the current encoding to UTF-32 and adds its preamble to the exported file:

@using System.Text

<DxGrid @ref="Grid"
        Data="@Data">
    <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>
</DxGrid>

<DxButton Text="Export to CSV" Click="ExportCsv_Click" />

@code {
    IEnumerable<object> Data { get; set; }
    IGrid Grid { get; set; }
    async Task ExportCsv_Click() {
       await Grid.ExportToCsvAsync("ExportResult", new GridCsvExportOptions() {
            Encoding = Encoding.UTF32,
            AddEncodingPreamble = true
        });
    }
}
See Also