0

I'm getting a mysterious error when trying to use the xlsx.writeBuffer() method in my Angular app to try and download an Excel file to the client browser.

After finishing all the changes that needed to be made to the workbook, I try to download it using the following code:

workBook.xlsx.writeBuffer().then((data) => {
      let blob = new Blob([data], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'});
      FileSaver.saveAs(blob, "SRS_Form.xlsx");
    });

But for some reason, the following error is always printed to the console:

ERROR Error: Uncaught (in promise): TypeError: t.toISOString is not a function TypeError: t.toISOString is not a function at u.p.DateFormat [as _format] (vendor.js:9222) at u.value (vendor.js:9222) at u.value (vendor.js:9222) at u.value (vendor.js:9222) at vendor.js:9222 at f (vendor.js:9236) at Generator._invoke (vendor.js:9236) at Generator.next (vendor.js:9236) at i (vendor.js:9222) at s (vendor.js:9222) at resolvePromise (polyfills.js:894) at resolvePromise (polyfills.js:846) at polyfills.js:956 at ZoneDelegate.invokeTask (polyfills.js:495) at Object.onInvokeTask (vendor.js:45277) at ZoneDelegate.invokeTask (polyfills.js:494) at Zone.runTask (polyfills.js:263) at drainMicroTaskQueue (polyfills.js:665) at ZoneTask.invokeTask [as invoke] (polyfills.js:580) at invokeTask (polyfills.js:1717)

I'm not sure what is causing this error but I've narrowed the source of it down to the writeBuffer() function specifically and I don't believe it has anything to do with the workbook I'm trying to pass into it since I'm able to save it in Node using writeFile().

I've been trying to debug this for hours so any advice would be much appreciated.

Useme Alehosaini
  • 2,998
  • 6
  • 18
  • 26
A. Lewis
  • 67
  • 8
  • Looks like an issue with date object. Are there any date related cells in your workbook? Also, if you could create a stackblitz example, that would help me in understanding problem faster – Prabh Nov 26 '20 at 02:45
  • I went through all the cells in my workbook and made sure that the value formatting was set to general. All of the values being added into the workbook are of type string so I can't figure out what the issue is. I'll put a Stackblitz example together to illustrate the issue better. Thanks for the help – A. Lewis Nov 26 '20 at 15:09

0 Answers0