我使用一个单元格来帮助触发我制作的电子表格中的功能
ie:当单元格A13 =“正在加载旧订单”时,执行此操作 它应该运行约4分钟,然后结束 然后重复此操作,直到代码在col C中找到“ 2015-11-09T22:40:56”为止
我发现,由于工作表的尺寸越来越大,其中一些电话花费的时间更长。
我追求一些使代码更高效的想法
预先感谢
function getOldOrders(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var status = ss.getSheetByName('Main');
var sheet = ss.getSheetByName('Summary');
var StatusCellToWatch = status.getRange("A13");
var offset = 0;
if (StatusCellToWatch.getValue() === "Loading Old Orders") {
try {
var beforedate = sheet.getRange(sheet.getLastRow() - 1,21).getValue();
}
catch(e) {
var beforedate = "2999-03-22T19:28:02";
}
//StatusCellToWatch.setValue(beforedate);
getOrders('&before='+beforedate,offset);
StatusCellToWatch.setValue('Loading Old Orders');
//Set sheet status so that the dataset just updates and grabs new orders
var data = sheet.getRange('C30000:C').getValues();
var search = "2015-11-09T22:40:56";
for (var i=0; i < data.length; i++) {
if (data[i][0] == search) {
StatusCellToWatch.setValue('');
FormatSummary();
}
}