我有一个(我认为是)简单的Google Apps脚本,该脚本从URL中获取参数,并根据行中的两个单元格是否与两个参数相匹配,使用它们将数据写入电子表格:
function doGet(e) {
var email = e.parameter.email;
var originalTitle = e.parameter.originalTitle;
var newTitle = e.parameter.newTitle;
var newAdditionalAuthors = e.parameter.newAdditionalAuthors;
var newTechnicalSessions = e.parameter.newTechnicalSessions;
var newApproval = e.parameter.newApproval;
var sh = SpreadsheetApp.openById("18vghxzzt27FcBOvoG8kIFFtswMB7XTsMRg60DJ6_-QM").getSheetByName("Responses");
var data = sh.getDataRange().getValues(); // read all data in the sheet
for (n=0;n<data.length;++n){
if (data[n][2] == email && data[n][3] == originalTitle){ //Find all rows where the email matches the submitter's and the title matches the original
data[n][3] = newTitle;
data[n][31] = newAdditionalAuthors;
data[n][33] = newTechnicalSessions;
data[n][34] = newApproval;
};
sh.getRange(1,1,data.length,data[0].length).setValues(data); // write back to the sheet
}
return ContentService.createTextOutput("Success. You may close this tab.");
}
但是,运行脚本似乎要花费相当可笑的时间,而且我在工作表中拥有的条目越多,情况就越糟。有人可以告诉我我在做什么错吗?