Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.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
Google apps script 快速循环浏览多个工作表以查找数据_Google Apps Script_Google Sheets_Custom Function - Fatal编程技术网

Google apps script 快速循环浏览多个工作表以查找数据

Google apps script 快速循环浏览多个工作表以查找数据,google-apps-script,google-sheets,custom-function,Google Apps Script,Google Sheets,Custom Function,大家好,我正在尝试编写一个自定义函数,该函数接受一对单元格,在电子表格中的所有工作表中循环查找相同的匹配单元格对,并从同一行返回另一个值 背景;表0是所有LOA和ID组合(基本上是位置和序列号)的主表,需要填写检查日期。执行这些检查的人员使用google drive上的LOA-ID组合+检查数据更新个人工作表。我试图让主控表自动更新,每当这些数据被添加 所有表格均采用相同的格式(LOA、ID在第1列和第2列,检验日期在第14列)。这是一个自定义函数,我使用它做我想做的,但工作速度非常慢。我如何让

大家好,我正在尝试编写一个自定义函数,该函数接受一对单元格,在电子表格中的所有工作表中循环查找相同的匹配单元格对,并从同一行返回另一个值

背景;表0是所有LOA和ID组合(基本上是位置和序列号)的主表,需要填写检查日期。执行这些检查的人员使用google drive上的LOA-ID组合+检查数据更新个人工作表。我试图让主控表自动更新,每当这些数据被添加

所有表格均采用相同的格式(LOA、ID在第1列和第2列,检验日期在第14列)。这是一个自定义函数,我使用它做我想做的,但工作速度非常慢。我如何让它跑得更快?每个细胞需要几秒钟;我需要运行超过10k+的电池

function findMatch(LOA,GRID) {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheets = ss.getSheets();
  var returnDate = "not found"

  for (var sheetNum = 1; sheetNum < sheets.length; sheetNum++){
     var ws = ss.getSheets()[sheetNum]

       for (var count = 1; count<ws.getLastRow(); count++){
       if (ws.getRange(count,1,1,1).getValues()==LOA && ws.getRange(count,2,1,1).getValues()==GRID)
       {
       returnDate = ws.getRange(count,14,1,1).getValue()
       break;
       }
       else
    {
    }  
       }

  }
  Logger.log(returnDate)
  return returnDate
函数findMatch(LOA,网格){
var ss=SpreadsheetApp.getActiveSpreadsheet();
var sheets=ss.getSheets();
var returnDate=“未找到”
对于(var sheetNum=1;sheetNum对于(var count=1;count来说,最佳做法是执行尽可能少的电子表格服务调用,尤其是避免在循环中调用。相反,使用getValues()检索批处理中的所有数据,并使用Javascript迭代该数据

function findMatch(LOA,GRID)
{
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheets = ss.getSheets();
  var returnDate = "not found", data;

  for (var sheetNum = 1; sheetNum < sheets.length; sheetNum++)
  {
     data = sheets[sheetNum].getDataRange().getValues();
     for (var count = 1; count < data.length; count++)
     {
       if (data[count][0] == LOA && data[count][1] == GRID)
       {
       returnDate = data[count][13];
       break;
       }
     }

  }
  Logger.log(returnDate);
  return returnDate;
}
函数findMatch(LOA,网格)
{
var ss=SpreadsheetApp.getActiveSpreadsheet();
var sheets=ss.getSheets();
var returnDate=“未找到”,数据;
对于(var sheetNum=1;sheetNum