blazor-devexpress-dot-blazor-dot-dxtreelist-dot-exporttoxlsasync-x28-system-dot-string-devexpress-dot-blazor-dot-treelistxlexportoptions-x29.md
Exports TreeList data in XLS format and downloads the resulting file to the client machine.
Namespace : DevExpress.Blazor
Assembly : DevExpress.Blazor.v25.2.dll
NuGet Package : DevExpress.Blazor
public Task ExportToXlsAsync(
string fileName,
TreeListXlExportOptions options = null
)
| Name | Type | Description |
|---|---|---|
| fileName | String |
The target stream for export.
|
| Name | Type | Default | Description |
|---|---|---|---|
| options | TreeListXlExportOptions | null |
An object that contains export options.
|
| Type | Description |
|---|---|
| Task |
The task that is completed when the file is exported.
|
Call the ExportToXlsAsync method to export TreeList data in XLS format. The method overloads allow you to write the result to a stream (ExportToXlsAsync(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 additional information about data export in the TreeList component, refer to the following topic: Export Blazor TreeList Data to XLS/XLSX.
The following example exports TreeList data to XLS format on a button click:
<DxButton Text="Export to XLS" Click="ExportXls_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 ExportXls_Click() {
await MyTreeList.ExportToXlsAsync("ExportResult");
}
}
If the TreeList is bound to a GridDevExtremeDataSource object, the following limitations apply:
Refer to the following articles for information about Microsoft Excel limitations:
ExportToXlsAsync(String, TreeListXlExportOptions)
See Also