title: How do I use promises in ExcelJS
body: <p>I have a node api that receives an xlsx file. It extracts records from that file and writes them to a database. </p>
  
  <p>in some cases the data will not write to the database because of missing related data. I want to catch all these errors before I return the results back to the user, so I need to use a promise.</p>
  
  <p>This is how <a href="https://www.npmjs.com/package/exceljs#rows" rel="nofollow noreferrer">the docs show</a> the worksheet.eachRow should work</p>
  
  <pre><code>worksheet.eachRow(function(row, rowNumber) {
      console.log('Row ' + rowNumber + ' = ' + JSON.stringify(row.values));
  });
  </code></pre>
  
  <p>the docs also say that exceljs has built in node promises <a href="https://www.npmjs.com/package/exceljs#0244" rel="nofollow noreferrer">excelJS Promises</a>, but the following code does not work </p>
  
  <pre><code>worksheet.eachRow(function(row, rowNumber) {
          console.log('Row ' + rowNumber + ' = ' + JSON.stringify(row.values));
  }).then((result)=&gt;{
    console.log("Done")
  })
  </code></pre>
  
  <p>I get the error <code>Cannot read property 'then' of undefined</code></p>