我想增加A1
单元格中的值。
function increment(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var cell = sheet.getRange("A1");
cellValue = cell.getValue("A1");
cell.SetValue(cellValue + 1);
}
我该怎么做?
答案 0 :(得分:7)
您正在使用参数调用getValue()
。此函数不带任何参数,如文档中所示:
https://developers.google.com/apps-script/reference/spreadsheet/range#getValue()
function increment(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var range = sheet.getRange("A1");
//Returns the value of the top-left cell in the sheet
var value = range.getValue();
range.setValue(value + 1);
}