Open foward opened 4 years ago
i have almost same problem, i just want read the first row. e.g. the header line of xlsx file. i wonder if there is a way to stop read whole file ?
i have to throw a error when trigger 'row' like this
new XLSX().extract(path, { sheet_nr: 1})
.on('row', function (row) {
// i got first row then throw error manually
throw Error('stop')
})
.on('error', function(error) {
console.log(error)
})
i have almost same problem, i just want read the first 200 rows and insert into mysql. i wonder if there is a way to stop read next 200 row in the xlsx sheet?
How to get the xlsx stream, and pause / resume this stream???
You can do this
let tmp = new XLSX().extract(path, { sheet_nr: 1})
tmp.on('row', function (row) { if(termination_condition) { tmp.emit('end'); } }) .on('end', function() {
})
Is there a way to stop the read until I have finished a preprocessing task?
new XLSX() .extract("../excel_source/Software List_1.2.xlsm", { sheet_name: "Products", ignore_header: 0 }) // or sheet_name or sheet_nr .on("sheet", function (sheet) { console.log("sheet", sheet); //sheet is array [sheetname, sheetid, sheetnr] }) .on("row", function (row) { // here can we do a continue or something like that in order to read the next row?
Thanks