get and set Value of a Cell do not work

前端 未结 2 1089
执笔经年
执笔经年 2020-12-18 12:13

I have trouble with getting a Value from a Cell in my Spreadsheet. I found the getCell()-method in the documentation but it does not work. It always just gets \"Range\" inst

相关标签:
2条回答
  • 2020-12-18 12:27

    both getRange() and getCell() return a Range object. You need to get call getValue() or getValues() on a range to get the data out. In this case as your first getRange("B1") is only referencing a single cell, you don't need the getCell(1,1)

    lastPlusOnes = ss.getRange("B1").getValue();
    

    https://developers.google.com/apps-script/reference/spreadsheet/range#getValue()

    for setting the same applies. a single value in a single cell would be:

    Range.setValue( number | string )
    

    or if you have a a bunch of rows and columns then first select the appropriate sized range and then use setValues([][])

    0 讨论(0)
  • 2020-12-18 12:32

    getCell() returns a Range object.. you need to add the .getValue() method to get the value of the cell in the range.

    https://developers.google.com/apps-script/reference/spreadsheet/range#getValue()

    0 讨论(0)
提交回复
热议问题