node-google-spreadsheet icon indicating copy to clipboard operation
node-google-spreadsheet copied to clipboard

Error: Cannot read property 'rowCount' of undefined for google spreadsheets that contain Chart sheets

Open johnbeech opened this issue 4 years ago • 1 comments

Using a multi-tab spreadsheet that contains a chart as one of the tabs:

Screenshot 2021-02-21 at 11 24 05

Example code:

function getCells(worksheet) {
  const { title, index } = (worksheet || {})._rawProperties
  try {
    await worksheet.loadCells()
    console.log(worksheet.rowCount)
  } catch (ex) {
    console.warn('Get cells failed for worksheet:', { title, index }, 'Error:', ex.message, ex)
  }
}

Throws an error in GoogleSpreadsheetWorksheet.js:131:32:

Get cells failed for worksheet: { title: '20x20 Time Analysis', index: 13 } Error: Cannot read property 'rowCount' of undefined TypeError: Cannot read property 'rowCount' of undefined
    at GoogleSpreadsheetWorksheet.get rowCount [as rowCount] (/Users/john/Local/google-spreadsheet-to-json/node_modules/google-spreadsheet/lib/GoogleSpreadsheetWorksheet.js:131:32)

Expected behaviour:

  • Not throw a "Cannot read property" error
  • Throw an error related to the type of spreadsheet
  • or: return 0 for rowCount

johnbeech avatar Feb 21 '21 11:02 johnbeech

Trying to recreate this, but I don't see how to make the chart take up the entire tab?

theoephraim avatar Jun 27 '23 06:06 theoephraim