I need to manipulate the data inside stream.on('data') body, but I get the following error: "error: Unsupported ZIP Compression method NaN stream on node". It only works when I manipulate the data inside stream.on('end') event, I'm trying to read large excel files
const readStreamExcelFile = function(stream, cb) {
const buffers = [];
stream.on("data", function(data) {
buffers.push(data);
const buffer = Buffer.concat(buffers);
const workbook = XLSX.read(buffer, { type: "buffer" });
const workbookSheets = workbook.SheetNames;
// With this callback I do some operations with data
cb(workbookSheets, workbook);
});
stream.on("end", function() {
/* Here I can manipulate data with this
const buffer = Buffer.concat(buffers);
const workbook = XLSX.read(buffer, { type: "buffer" });
const workbookSheets = workbook.SheetNames;
cb(workbookSheets, workbook);
*/
resolve();
});
};