Skip to content

DevExpress-Examples/devextreme-treelist-export-to-excel

Repository files navigation

TreeList for DevExtreme - Export to Excel

While TreeList does not have a built-in export feature, you can use the ExcelJS and FileSaver libraries to access a similar functionality.

Implementation details

  • Install or reference the ExcelJS and file-saver packages.
  • Add a reference to the excelExporter file (see the excelExporter file for your framework below).
  • Define the export button in the TreeList toolbar.
  • Implement the export button's onClick handler and call the exportTreeList method.
function exportToExcel() {
  const workbook = new ExcelJS.Workbook();
  const worksheet = workbook.addWorksheet('Employees');

  exportTreeList({
    component: treeList,
    worksheet,
  }).then(() => {
    workbook.xlsx.writeBuffer().then((buffer) => {
      saveAs(
        new Blob([buffer], { type: 'application/octet-stream' }),
        'Employees.xlsx',
      );
    });
  });
}

Files to Review

Documentation

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)