Support Stream writing in browser
🚀 Stream writing should be possible in browser
If you export large excel file in browser, it crashes on memory. Stream writing which is supported in NodeJS should be supported in browser.
Required changes:
- update node-compress-commons to use duck typing to identify Stream instead of "instanceof" Release: https://github.com/jiridudekusy/node-compress-commons/releases/tag/v2.1.1-browser
- update archiver-utils to use duck typing to identify Stream instead of "instanceof" Release: https://github.com/jiridudekusy/archiver-utils/releases/tag/v2.1.0-browser
- update exceljs to use Buffer.isBuffer instead of "instanceof" Release: https://github.com/jiridudekusy/exceljs/releases/tag/v3.8.2-stream-browser1
I would also like this capability! I have an Angular app that display data in a grid and I need to export that data to excel. This works without any issues for small files using FileSaver.js and the workbook.xlsx.writeBuffer() method. But large exports (40+ columns and 100K+ rows), writeBuffer errors out and streaming does not seem to work in the browser (I am using StreamSaver.js for this).
is there any status on this ?
@ChristopherDuda How do you use streamsave.js btw ? Do you have some sample code?
found it...
if anyone else wonders
import streamSaver from 'streamsaver'
const fileStream = streamSaver.createWriteStream('filename.xlsx', {
writableStrategy: undefined, // (optional)
readableStrategy: undefined // (optional)
})
const writer = fileStream.getWriter()
workbook.xlsx.write(writer).then(()=>{
writer.close()
})
```
@ChristopherDuda
Did you have a better way ? Looks like it take a while...
Is there any progress?
The sample code written by @vegarringdal works fine but, it doesn't seem to work for TS. The error message is like below.
[tsl] ERROR in .../Excel.vue.ts(32,23)
TS2345: Argument of type 'WritableStreamDefaultWriter<any>' is not assignable to parameter of type 'Stream'.
Type 'WritableStreamDefaultWriter<any>' is missing the following properties from type 'Stream': pipe, addListener, on, once, and 12 more.
@vegarringdal https://codesandbox.io/s/use-streamsaver-to-save-file-kjrxh?file=/src/index.js
@ddaylucifer 👍 Cool thx, Ill save this for later, not using exceljs for saving files. Have you tried reading files? Remember that was really slow too.
@vegarringdal I only use '\t' and '\r\n' to write(steamSaver.writer.write) Excel in the reader loop,when the reader is done use steamSaver.write.close,steamSaver has good example
ps:You can include '\t' and '\r\n' directly in the string stream,so just write into excel
@XiaoBai-Game
@vegarringdal https://codesandbox.io/s/use-streamsaver-to-save-file-kjrxh?file=/src/index.js
hi, brother. can your code handle large data set without OOM ?
4 years....later.
any updates ?