I'm trying to create an Excel file in a firebase function.
Running locally, this writes an xls file.
const xls = json2xls(data);
fs.writeFileSync(`${filename}.xlsx`, xls, 'binary');
But run in a firebase function, this downloads a broken file.
const xls = json2xls(data);
res
.status(200)
.set('Content-Type', 'application/vnd.openxmlformats')
.set("Content-Disposition", `attachment; filename=${filename}.xlsx`)
.send(xls);
Both files are named correctly. They're 'Office Open XML spreadsheet' files. The one from firebase is 30% larger than the once created locally, but otherwise I can't see any difference.
What am I doing wrong here? How do I go about debugging this?