I would like to use Google SpreadsheetApp to write a 2D array into a sheet. Trying
sheet.getRange(sheet.getLastRow() + 1, 1, array2d.length, array2d[0].length).setValues(array2d);
leads to the following error:
"The number of rows in the data does not match the number of rows in the range. The data has 4 but the range has 3."
How is it possible to get an error like this from this line of code? I use the dimensions of the array to specify the range in the spreadsheet, so how can it be that they don't match?
(The line is part of https://github.com/alpatania/sassafras (function appendData_
in supporting_code
).)
getRange()
is not equal to the number of rows that exist insetValues()
. Soarray2d.length
= 3 rows but, for some reason,array2d
has 4 rows - which does seem odd. The only way to be more specific is if you would share a copy of your spreadsheet (less private or confidential data, of course). Then, we can see the actual data and also compare it to the code when array2d is/was created. – Tedinozconsole.log({message:"the data", arraylen: array2d.length, .....})
– tehhowch