Skip to main content
All docs
V24.2

DxTreeList.ExportToXlsxAsync(String, TreeListXlExportOptions) Method

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

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

Declaration

public Task ExportToXlsxAsync(
    string fileName,
    TreeListXlExportOptions options = null
)

Parameters

Name Type Description
fileName String

The name of the resulting file.

Optional Parameters

Name Type Default Description
options TreeListXlExportOptions null

An object that contains export options.

Returns

Type Description
Task

The task that is completed when the file is downloaded.

Remarks

Call the ExportToXlsxAsync method to export TreeList data in XLSX format. The method overloads allow you to write the result to a stream (ExportToXlsxAsync(Stream, TreeListXlExportOptions)) or to a file downloaded to a client machine (the current overload).

The method accepts a TreeListXlExportOptions 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 Data in Blazor TreeList.

Run Demo: TreeList - Export

Example

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

<DxButton Text="Export to XLSX" Click="ExportXlsx_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 ExportXlsx_Click() {
        await MyTreeList.ExportToXlsxAsync("ExportResult");
    }
}

Export Specifics and Limitations

  • Content of templates is not exported.
  • Custom summaries implemented in the CustomSummary event are exported as plain text.
  • Data columns anchored to the right edge become regular columns, while columns anchored to the components’s left edge remain frozen.
  • The TreeList component filters and sorts selected rows on the client side. Filtering and sorting may differ in the resulting document because export depends on database collation.
  • Appearance settings applied by style settings or in the CustomizeElement event handler are not exported. You can handle the CustomizeCell event to customize element appearance in the the exported document.
  • Excel permits up to seven nesting levels in outlines. Deeper nesting levels are exported on the seventh nesting level.

Refer to the following articles for information about Microsoft Excel limitations:

See Also