Skip to main content
All docs
V25.1
  • DxTreeList.ExportToCsvAsync(String, TreeListCsvExportOptions) Method

    Exports TreeList data in CSV format and downloads the resulting file to the client machine.

    Namespace: DevExpress.Blazor

    Assembly: DevExpress.Blazor.v25.1.dll

    NuGet Package: DevExpress.Blazor

    Declaration

    public Task ExportToCsvAsync(
        string fileName,
        TreeListCsvExportOptions options = null
    )

    Parameters

    Name Type Description
    fileName String

    The name of the resulting file.

    Optional Parameters

    Name Type Default Description
    options TreeListCsvExportOptions null

    An object that contains export options.

    Returns

    Type Description
    Task

    The task that is completed when the file is downloaded.

    Remarks

    Call the ExportToCsvAsync method to export data in CSV format. Note that only data cell values are exported - summaries and cell style settings are ignored.

    The method overloads allow you to write the result to a stream (ExportToCsvAsync(Stream, TreeListCsvExportOptions)) or to a file downloaded to a client machine (current overload). Methods accept a TreeListCsvExportOptions object as a parameter. You can use this parameter to set up export settings.

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

    Run Demo: TreeList - Export

    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.

    Example

    The following example exports TreeList data to CSV format on a button click:

    <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");
        }
    }
    
    See Also