Generate large file
- Dominant language
- JavaScript
- Stars
- 15.5k
- Forks
- 2k
- PR merge metrics
- No merged PRs in 30d
Description
What is the recommended way to export large file?
```js
export async function export(ctx: koa.Context) {
ctx.response.attachment("report.xlsx")
ctx.status = 200
const workbook = new Excel.Workbook()
const worksheet = workbook.addWorksheet("report")
worksheet.columns = [
{ header: 'Id', key: 'id', width: 10 },
{ header: 'Name', key: 'name', width: 32 },
{ header: 'D.O.B.', key: 'DOB', width: 10, outlineLevel: 1 }
];
// million rows
for(const row of fetchDataFromDatabaseWithCursor()){
await worksheet.addRow(row);
}
await workbook.xlsx.write(ctx.res)
ctx.res.end()
}
```
I have a code like the above mentioned script , I want to send file data to user in `for` loop too , not at the end of loop
How can I do it? if I move `workbook.xlsx.write` into loop it create only 1 row
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.