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.