It's not possible to send a large XLS file using a stream writter
See original GitHub issueHello!
I’m trying to send a large XLS document using WorkbookWriter
over HTTP.
Expected: Receiving file, chunk by chunk. File should be OK.
Actual: Chrome shows “Starting - 0 B/s - 0 B” about a minute, then I get “Failed - Network error”.
Info: It works good with small data amount.
Please, check the code sample below.
'use strict';
const Excel = require('exceljs');
const http = require('http');
const async = require('async');
http.createServer((request, response) => {
let workbook = new Excel.stream.xlsx.WorkbookWriter({
stream: response
});
let worksheet = workbook.addWorksheet('work-sheet');
worksheet.columns = [{header: 'field', key: 'field'}];
response.writeHead(200, {
'Content-Disposition': `attachment; filename="export.xlsx"`,
'Transfer-Encoding': 'chunked',
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
});
let count = 0;
async.whilst(() => {
return count < 1000;
}, callback => {
count++;
console.log(`Write row ${count}`);
worksheet.addRow({field: 'test'}).commit();
setTimeout(() => {
callback(null, count);
}, 1000);
}, (err, n) => {
workbook.commit().then(() => {
console.log('done');
});
});
}).listen(2000);
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:14 (1 by maintainers)
Top Results From Across the Web
Problem when using a StreamWriter for writing very large files.
This works fine for most of the data. There is one table that generated a very large flat file (over 18gig). The data...
Read more >c# - Stream out large datatable to excel file - Stack Overflow
You run out of memory because the whole table is written to memory first regardless if the StreamWriter is flushed or not before...
Read more >Stream in C# Tutorial: StreamReader & StreamWriter [Example]
This tutorial covers basic to the advanced topic on C# Stream. Learn StreamReader and StreamWriter with detailed code examples.
Read more >Reading and writing to file - PhpSpreadsheet Documentation
A typical use of this feature is when you need to read files uploaded by your users, and you don't know whether they...
Read more >How read/write Excel file in chunks or without loading ... - Reddit
As others have mentioned, Excel files (either xls or xlsx) are virtual filesystems (zipped) and not designed for streaming record by record.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi guys! My workaround (using a temporary file) here: https://github.com/bushev/node-lib/blob/master/lib/controllers/crudcontroller.js#L1354
is this issue solved? my program work like this…