theoephraim / node-google-spreadsheet

Google Sheets API wrapper for Javascript / Typescript
https://theoephraim.github.io/node-google-spreadsheet
The Unlicense
2.31k stars 391 forks source link

using loadCells with GridRangeObject. Data inside GRO seems to get "lost" #347

Closed christopherreay closed 1 year ago

christopherreay commented 4 years ago

post complete

So I have trapped the uncaught error, and am writing this from the output:

the stack looks like (top at the top):

(anonymous)
arrayEach
forEach
_fillCellData
_updateOrCreateSheet
(anonymous)
arrayEach
forEach
loadCells

inside the loadCells frame, this is the value of filtersArray, defined on line 314 in GoogleSpreadsheet.js

[
  {
    sheetId: 0,
    startRowIndex: 20,
    endRowIndex: 20,
    startColumnIndex: 0,
    endColumnIndex: 12
  }
]

by the time we arrive at _fillCellData, line 57, GoogleSpreadsheetWorksheet.js, we have this:

_fillCellData(dataRanges) {
    _.each(dataRanges, (range) => {  // range = {startRow: 20, columnMetaData: Array(12)}
      const startRow = range.startRow || 0; // startRow = 20
      const startColumn = range.startColumn || 0; // startColumn = 0
// this next assignment causes an error:
      const numRows = range.rowMetadata.length; // rowMetadata = undefined
      const numColumns = range.columnMetadata.length;
christopherreay commented 4 years ago

OK, I worked out the bug.

rowMetadata is not loaded if there is only 1 row being loaded, using a GridRangeObject

I have changed my code to load 2 rows.

[
  {
    sheetId: 0,
    startRowIndex: 20,
    endRowIndex: 21,
    startColumnIndex: 0,
    endColumnIndex: 12
  }
]
theoephraim commented 3 years ago

Hi @christopherreay - do you have any idea if this seemed to be an issue with the google API or this module?

christopherreay commented 3 years ago

Not the faintest idea my friend :) I didnt look through the code in detail, I was on a deadline. I can try and have a look sometime in the next couple of weeks if you would like?

theoephraim commented 3 years ago

All good - I'll take a look. Thanks!

theoephraim commented 1 year ago

I can't reproduce this. If this is still an issue, please reopen with more details.