question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Worksheet.Eachrow Break or stop

See original GitHub issue

Hi, i have tried your npm package, lets assume one scenario,

i have uploading sheet and reading data, in that first record i got error, then have to send res.send error statuscode with client side message. Still now also eachrow loop continue, after i have sent the response. i need to break(stop) the loop.

worksheet.eachRow({ includeEmpty: false }, function(row, rowNumber) {

//here i'm doing some validation, the upload data was wrong. so i have to stop the loop don't want further process.

// currently i have pass the error message using res.send but the loop was hitting again and again.
and also i have getting unhandledrejection warning message how can i avoid.
});

Gopal R.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

5reactions
jledentucommented, Oct 22, 2020

@harloveleenKaur Using a return statement doesn’t work. A return in the iteratee doesn’t break the loop.

But you’re right about throwing an error:

try {
  worksheet.eachRow({ includeEmpty: false }, function(row, rowNumber) {
    if (/* Validation of the row fails */) {
      throw new Error();
    }
  });
} catch (error) {}
1reaction
RGKrish183commented, Nov 30, 2018

Hi @ahdigital,

This is @GRathinavelu (From Personal Id),

I have tried based on which i mention previously, after some google i have go with ALASQL, use the npm of multer move the files to my server, and use the path to get the data based on my SQL QUERIES.

npm i alasql

if i need to validate some kind of data is available or not, i have simple use select * from tbl where some quires. we don’t need to loop that, and also we create temp tables also on run time.

So, as per my case I HAVE SUGGESTED ALASQL instead of EXCELJS

Gopal R.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Worksheet.Eachrow Break or stop · Issue #644 - GitHub
i have uploading sheet and reading data, in that first record i got error, then have to send res.send error statuscode with client...
Read more >
How to break out of a eachRow method? - node.js
{ // get only the nb number of rows var row = sheet. getRow(rowNumber); var msisdn = row. getCell(1). value; var matricule =...
Read more >
Exit for each row - Help - UiPath Community Forum
Its iterating properly within the sheet. But moment its found the empty row the bot is not stopping the loop.
Read more >
exceljs: Excel Workbook Manager - Gitee
Read, manipulate and write spreadsheet data and styles to XLSX and JSON. Reverse engineered from Excel spreadsheet files as a project. Installation. npm...
Read more >
How To Use For Each Loops in UiPath (Full Tutorial) - YouTube
The guide covers Each Excel Row, For Each Row in Data Table, For Each, While and ... To stop a For Each loop,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found