【发布时间】:2015-03-28 21:22:08
【问题描述】:
我已经使用谷歌脚本一周了,我已经尽可能多地搜索以获得答案。有人可以帮帮我吗?我编写了一个简单的脚本来根据课程编号的最后三位(即 PSY-250-400)评估课程是否在线。该脚本工作正常,我将结果推送到数组的末尾。我不知道如何写回谷歌表格。下面是我所拥有的。目前它将根据第一个结果(在线课程)设置值。所以所有值都设置为在线。我现在在 7 行上运行它,但需要在 20,000 行上运行它。
function onlineonly(online){
var sheet = SpreadsheetApp.getActiveSheet();
var students = sheet.getRange('A2:D7').getValues();
var online = ["400","401","403","404","600"];
var m;
var section;
for(var i=0; i<students.length; ++i){
section = students[i][3].substring(8,13);
for(var j = 0;j<online.length; j++){
if(section===online[j]){
section = m;
}
}
if(section === m){
students[i].push("online");
} else {
students[i].push("not online");
}
var method = [];
for(var k = 0; k<students.length; k++){
if(students[i][4]=== "online"){
method = "online";
} else {
method = "in person";
}
sheet.getRange('c2:c7').setValue(method);
}
}
}
【问题讨论】:
标签: javascript google-apps-script google-spreadsheet-api