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

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

Open christopherreay opened this issue 4 years ago • 4 comments

*** 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 avatar May 08 '20 14:05 christopherreay

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
  }
]

christopherreay avatar May 08 '20 14:05 christopherreay

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

theoephraim avatar Nov 30 '20 19:11 theoephraim

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?

christopherreay avatar Nov 30 '20 19:11 christopherreay

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

theoephraim avatar Nov 30 '20 19:11 theoephraim

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

theoephraim avatar Jun 27 '23 06:06 theoephraim