Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to stop the read until I have finished a preprocessing task? #315

Open
foward opened this issue Aug 5, 2020 · 3 comments

Comments

@foward
Copy link

foward commented Aug 5, 2020

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

@MuLoo
Copy link

MuLoo commented Oct 15, 2021

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)
})

@combuilder
Copy link

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???

@Santosh-745
Copy link

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() {

})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants