Excel Export
The TreeList provides options for exporting its data to Excel.
To enable the Excel export, import the ExcelModule and add the kendo-treelist-excel
component to the Kendo UI TreeList for Angular. To initiate the export, use the kendoTreeListExcelCommand
directive or the saveAsExcel
method.
Configuration
With regard to its Excel export, the TreeList enables you to:
- Export specific data
- All pages
- Expanded state
- Customize the exported columns
- Customize the exported workbooks
- Trigger the export externally
- Make item levels collapsible
Exporting Specific Data
By default, the TreeList exports its current data. To export data that is different from the current TreeList data, specify a custom fetchData
function. The function should return an ExcelExportData
object.
Exporting Specific Asynchronous Data
If the export data needs to be asynchronously loaded, you can set an Observable
to the data
field.
All Pages
By default, the TreeList exports all pages of the current data. To export only the current page set the allPages
option to false
.
Expanded State
By default, the TreeList expands all items during export. To export the data with the currently expanded items, set expandAll
to false
.
Specifying Exported Columns
By default, the TreeList exports its current columns. To export columns that are different from the current TreeList columns, include the <kendo-excelexport-column>
and <kendo-excelexport-column-group>
components inside the <kendo-treelist-excel>
component.
Customizing Exported Columns
The Excel export functionality is configured to work with the TreeList data rather than with the cell's content. That is why the dates in the exported sheet have no format applied.
To customize all cells in a given column, you can set the cellOptions property of the <kendo-excelexport-column>
component. To apply specific currency or percentage format, use the format option. For more details on the supported Excel formats, refer to the Microsoft Create a custom number format page.
<kendo-treelist-excel fileName="Employees.xlsx">
<kendo-excelexport-column field="name" title="Name">
</kendo-excelexport-column>
<kendo-excelexport-column
field="hireDate"
title="Hire Date"
[cellOptions]="{ format: 'dd/mm/yyyy' }"
>
</kendo-excelexport-column>
</kendo-treelist-excel>
Customizing Generated Workbooks
The excelExport
event allows you to customize the generated Excel document. The workbook event argument exposes the generated Excel workbook configuration.
Triggering Export Externally
The TreeList enables you to trigger the export operation by calling the saveAsExcel
method.
Making Item Levels Collapsible
The collapsible
option allows you to create a collapsible outline for each item level.
The option is only applicable if the TreeList has footers.
Known Limitations
- During the export to Excel, the cell templates of the TreeList are not evaluated. Instead, the TreeList exports only the data and the field value is serialized to preserve the type information. To tweak the cell content, use an accessor or transform the data in advance.
- During the export to Excel, the TreeList does not use column formats. Column formats are incompatible with Excel. For more information, refer to the page on the Excel-supported formats.
- The maximum size of the exported file to Excel has a system-specific limit. For large data sets, it is highly recommended that you use a server-side solution.
- When you export the TreeList to Excel in older browsers, such as Internet Explorer 9 and Safari, you have to implement a server proxy. For more information, refer to the
proxyUrl
configuration.