'I export my data to Excel but i get this error: Cannot read properties of undefined (reading 'editing')

I Want to export my material table data to Excel but when I click to download I get error in console: Cannot read properties of undefined (reading 'editing')

(I use "xlsx": "^0.18.0")

<div onClick={downloadExcel} className="downloadExcel">
      <img src="/assets/excel-svgrepo-com.svg" />
</div>

and my downloadExcel function is:

  const downloadExcel = () => {
    const newData = Apiary.map((row) => {
      delete row.tableData;
      return row;
    });
    const workSheet = XLSX.utils.json_to_sheet(newData);
    const workBook = XLSX.utils.book_new();
    XLSX.utils.book_append_sheet(workBook, workSheet, "students");
    //Buffer
    let buf = XLSX.write(workBook, { bookType: "xlsx", type: "buffer" });
    //Binary string
    XLSX.write(workBook, { bookType: "xlsx", type: "binary" });
    //Download
    XLSX.writeFile(workBook, "لیست زنبورستان.xlsx");
  };

when I onClick img my react is freeze and stop How can I fix this error?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source