Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scripting GoogleSheets脚本——新手_Scripting_Google Sheets - Fatal编程技术网

Scripting GoogleSheets脚本——新手

Scripting GoogleSheets脚本——新手,scripting,google-sheets,Scripting,Google Sheets,我错过了显而易见的*方式 此脚本有什么问题: function setMenuChoices() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; var cell = sheet.getRange("P28"); If(cell == "X") cell.setValue(" "); else cell.setValue("X"); } 而不是 If(cell == "

我错过了显而易见的*方式 此脚本有什么问题:

function setMenuChoices() {
 var ss = SpreadsheetApp.getActiveSpreadsheet();
 var sheet = ss.getSheets()[0];

 var cell = sheet.getRange("P28");
 If(cell == "X") cell.setValue(" ");
 else cell.setValue("X");
}
而不是

If(cell == "X") cell.setValue(" ");
使用


请考虑接受我的答案(点击复选标记),如果它对你有用(2的声誉为你)。
if(cell.getValue() == "X") cell.setValue(" ");