工作表IF语句的变量未定义的谷歌脚本

时间:2018-01-24 05:33:54

标签: variables if-statement google-apps-script google-sheets

var app = spreadhseetapp; 

给我的错误信息“spreadhseetapp”没有定义。我怎样才能解决这个问题?

function myFunction() {

  //var app = spreadhseetapp;

  var activesheet = getactivespreadsheet().getactivesheet();

  var workingcell = activesheet.getrange(1, 3).getvalue();

  if(workingcell > 1){

 activesheet.getrange(1, 4).setvalue("Dues Paid");
 }

}

Google Doc

1 个答案:

答案 0 :(得分:0)

function myFunction() {

  //var app = spreadhseetapp;

  var activesheet = getactivespreadsheet().getactivesheet();

  var workingcell = activesheet.getrange(1, 3).getvalue();

  if(workingcell > 1){

 activesheet.getrange(1, 4).setvalue("Dues Paid");
 }

}
  

代码应以区分大小写(例如函数名称)格式编写。   请检查以下代码并检查其是否有效。

function myFunction() {

  var app = SpreadsheetApp;

  var activesheet = app.getActiveSpreadsheet().getActiveSheet()

  var workingcell = activesheet.getRange(1, 3).getValue();

  if(workingcell > 1){

 activesheet.getRange(1, 4).setValue("Dues Paid");
 }

}