-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Description
I have a code in which i create a pretty big xlsx, for that I needed to use stream function, avoiding heap memory errors, everything worked fine on local environment, but in the moment I passed to a server, the stream files always returns a corrupted file, which I can only open in Excel with the repair tool, and that doesn't work every time.
At the same time, if the file is created with xlsx.writeFile(); it can be opened correctly.
My server specs are:
OS: Ubuntu 20.04 LTS
RAM: 8 Gb
Code:
let min = new Date(date.min);
let max = new Date(date.max);
const dir = `/home/data/uploads/reports/${req.user._id}/`;
if(!fs.existsSync(dir))shelljs.mkdir("-p", dir);
const filename = `report-${(new Date().getTime())}.xlsx`;
const file = `${dir}/${filename}`;
const stream = fs.createWriteStream(file);
const options = {
stream: stream,
useStyles: true,
};
const workbook = new Exceljs.stream.xlsx.WorkbookWriter(options);
const sheet = workbook.addWorksheet("reports");
// process here (committing every row I create)
// then committing the unique sheet I need
sheet.commit();
await workbook.commit();
Please help
alexbjorlig and alex-ketch
Metadata
Metadata
Assignees
Labels
No labels