My use case:
My users upload a template xlsx file and the app is meant to populate its columns with data. This template is meant to be used over and over, so instead of editing it directly I want to create a copy of the file, edit that file, save, and return it.
I’m using exceljs and I can create a copy of the file easily enough:
const newWB = new ExcelJS.Workbook();
const worksheet = newWB.addWorksheet();
worksheet.model = JSON.parse(JSON.stringify(originalWorksheet.model));
However, I have no idea how to return this or save. If I use newWB.xlsx.writeFile("Schedule_Filled.xlsx")
I get an error, and I wouldn’t know how to retrieve the file anyway.
I thought I found the answer in this thread but it looks like the endpoint is no longer around:
I couldn’t find anything similar in the docs.
How do I save this new file and return it?