-
Notifications
You must be signed in to change notification settings - Fork 34
Description
We want to exit the "row" function and switch to the "end" function on the specified row.
We found such a solution.
//logic
worksheet.on('row', (row) => {
if (headerResult.errorHeaders.length > 0) {
throw('ABORT')
}
});
// node_modules/xlsx-stream-reader/lib/workbook.js
//we add try catch block
parser.on('closetag', function (nodeName) {
try {
if (nodeName === 'rPh') {
self.abortBook = false
return
}
if (self.abortBook) return
if (tmpNodeEmit) {
entryHandler.call(self, tmpNode)
tmpNodeEmit = false
tmpNode = []
} else if (tmpNode.length && tmpNode[tmpNode.length - 1] && tmpNode[tmpNode.length - 1].name === nodeName) {
tmpNode.push('')
entryHandler.call(self, tmpNode)
tmpNodeEmit = false
tmpNode = []
}
tmpNode.splice(-1, 1)
} catch (error) {
self.emit('error', error)
if (error.indexOf('ABORT') >= 0) {
self.abortBook = true;
self.abort();
}
}
})