Replies: 2 comments
-
I have the same question. I have // ...
fastify.get('/', { schema: REQUEST_SCHEMA }, async (req, reply) => {
reply.header('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
reply.header('Content-Disposition', 'attachment; filename=export.xlsx');
const workbook = new ExcelJS.stream.xlsx.WorkbookWriter({
stream: reply.raw,
useStyles: true,
useSharedStrings: true,
});
const worksheet = workbook.addWorksheet('Export');
worksheet.columns = ['1', '2', '3'];
const row = ['1', '2', '3'];
worksheet.addRow(row).commit();
await workbook.commit();
});
// ... |
Beta Was this translation helpful? Give feedback.
0 replies
-
Ok, I was able to fix this issue by slightly changing the snippet above // ...
fastify.get('/', { schema: REQUEST_SCHEMA }, async (req, reply) => {
reply.header('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
reply.header('Content-Disposition', 'attachment; filename=export.xlsx');
const passThrough = new PassThrough({ highWaterMark: 64 * 1024 });
const workbook = new ExcelJS.stream.xlsx.WorkbookWriter({
stream: passThrough,
useStyles: true,
useSharedStrings: true,
});
const worksheet = workbook.addWorksheet('Export');
worksheet.columns = ['1', '2', '3'];
const row = ['1', '2', '3'];
reply.send(passThrough);
worksheet.addRow(row).commit();
await workbook.commit();
});
// ... |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is it possible to stream as xlsx file ? and not a zip file ?
thanks
Beta Was this translation helpful? Give feedback.
All reactions