Skip to main content
All docs
V24.2

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

TreeListCsvExportOptions.AddEncodingPreamble Property

Specifies whether to include the encoding preamble at the beginning of the exported CSV file.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
[DefaultValue(false)]
public bool AddEncodingPreamble { get; set; }

#Property Value

Type Default Description
Boolean false

true to add the preamble; otherwise, false.

#Remarks

A Preamble is a byte array that specifies the encoding used to create a file. You can add this byte sequence to the exported CSV file for other tools to determine the byte order and UTF type. The TreeList uses the GetPreamble() method to identify the used encoding.

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

Razor
@using System.Text

<DxButton Text="Export to CSV" Click="ExportCsv_Click" />
<DxTreeList Data="TreeListData" KeyFieldName="Id" ParentKeyFieldName="ParentId" @ref="MyTreeList">
    <Columns>
        <DxTreeListDataColumn FieldName="Name" Caption="Task" />
        <DxTreeListDataColumn FieldName="EmployeeName" />
        <DxTreeListDataColumn FieldName="StartDate" />
        <DxTreeListDataColumn FieldName="DueDate" />
    </Columns>
</DxTreeList>

@code {
    ITreeList MyTreeList { get; set; }

    async Task ExportCsv_Click() {
        await MyTreeList.ExportToCsvAsync("ExportResult", new TreeListCsvExportOptions() {
            Encoding = Encoding.UTF8,
            AddEncodingPreamble = true
        });
    }
}
See Also