Excel Export
The TreeList provides built-in Excel export for hierarchical data. Add the Excel command to the toolbar to let users download the current TreeList data as an Excel workbook.
For a runnable example, refer to the TreeList Excel export demo.
Enable Excel Export
To enable Excel export:
- Include the JSZip library on the page.
- Add the
excelcommand to the TreeListtoolbarconfiguration. - Configure the
exceloptions.
Starting with v2023.3.1115, the JSZip library is no longer distributed with the Kendo UI for jQuery scripts. Load it from an official distribution channel such as
unpkg.
The following example adds an Export to Excel button to the TreeList toolbar and names the exported workbook.
<script src="https://unpkg.com/jszip/dist/jszip.min.js"></script>
<div id="treelist"></div>
<script>
$("#treelist").kendoTreeList({
toolbar: ["excel"],
columns: [
{ field: "Name", title: "Name" },
{ field: "Position", title: "Position" }
],
dataSource: [
{ id: 1, parentId: null, Name: "Jane Doe", Position: "Chief Executive Officer" },
{ id: 2, parentId: 1, Name: "John Doe", Position: "Chief Technology Officer" }
],
excel: {
fileName: "Employees.xlsx"
}
});
</script>
Export All Pages
By default, the TreeList exports the current page. Set excel.allPages to true to export all pages of data.
excel: {
allPages: true,
fileName: "Employees.xlsx"
}
Export Programmatically
You can call the saveAsExcel method when a user interacts with an external element to export the TreeList data to an Excel file.
$("#export").on("click", function() {
var treeList = $("#treelist").data("kendoTreeList");
treeList.saveAsExcel();
});
The excelExport event fires before the TreeList saves the generated workbook. Use its e.workbook argument to customize the workbook.