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.

TypeError: Cannot read property 'sheets' of undefined

See original GitHub issue

I got this error when I tested the parsing process from an excel file. Hope someone can help me with this

TypeError: Cannot read property 'sheets' of undefined
    at _callee10$ (/Users/tvi/Documents/BCM projects/cvd-genomics/node_modules/exceljs/dist/es5/xlsx/xlsx.js:553:43)
    at tryCatch (/Users/tvi/Documents/BCM projects/cvd-genomics/node_modules/regenerator-runtime/runtime.js:65:40)
    at Generator.invoke [as _invoke] (/Users/tvi/Documents/BCM projects/cvd-genomics/node_modules/regenerator-runtime/runtime.js:303:22)
    at Generator.prototype.(anonymous function) [as next] (/Users/tvi/Documents/BCM projects/cvd-genomics/node_modules/regenerator-runtime/runtime.js:117:21)
    at asyncGeneratorStep (/Users/tvi/Documents/BCM projects/cvd-genomics/node_modules/exceljs/dist/es5/xlsx/xlsx.js:3:103)
    at _next (/Users/tvi/Documents/BCM projects/cvd-genomics/node_modules/exceljs/dist/es5/xlsx/xlsx.js:5:194)
    at <anonymous>

Excel File: TEST.xlsx

exceljs version: 2.0.1

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:32 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
amit-coditascommented, Sep 27, 2019

Not sure of the exact root cause, but opening the file in Excel and saving it again works.

3reactions
zhukovsvcommented, Apr 6, 2021

Hi Everyone,

I reproduced this issue: Failed: Cannot read property ‘sheets’ of undefined

Configuration settings:

  1. node - v: 14.16.0

  2. “exceljs”: “^4.2.1”

  3. test File: testFile.xlsx

  4. Code:

const ExcelJS = require('exceljs');
const pageComparisonXLSXFilePath = './testFile.xlsx';
const workbook = new ExcelJS.Workbook();
await workbook.xlsx.readFile(pageComparisonXLSXFilePath); 
const worksheet = workbook.getWorksheet(1);
const rowC = worksheet.rowCount;
for (const row of worksheet.getRows(1, rowC)) {
  console.log(row.values);
}

Error raises during next line execution: await workbook.xlsx.readFile(pageComparisonXLSXFilePath);

  1. Steps to reproduce: 1. Download file -> exec code -> exception: Failed: Cannot read property ‘sheets’ of undefined. but 2. If I open this file by MSExcel and then simply save this file and close it -> code executes correctly.

Could you help me?

Regards, Sergei.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exceljs - TypeError: Cannot read property 'sheets' of undefined
Exceljs - TypeError: Cannot read property 'sheets' of undefined ... I got this issue when I tried to read an excel file and...
Read more >
App script for a sheet stopped working - TypeError
App script for a sheet stopped working - TypeError: Cannot read property 'source' of undefined - Google Docs Editors Community.
Read more >
Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError: Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
Uncaught TypeError : Cannot read properties of undefined
The solution to TypeError: Cannot read properties of undefined ... The root cause of the error is that the declared variable doesn't have...
Read more >
What does 'TypeError: Cannot read property '1' of undefined ...
It generally means that at the point of execution, the variable/object holding the property cannot be found by the script. It may be...
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