繁体   English   中英

异常:服务电子表格在访问 ID 为 XXX 的文档时超时

[英]Exception: Service Spreadsheets timed out while accessing document with id XXX

免责声明,我还是个新手,所以我真的需要你的帮助。

起初,我创建了一个电报机器人,用于根据名称在电子表格中搜索/查找数据。 一切顺利,直到我现在使用的电子表格有一行 50,000++,现在我的机器人不像以前那样运行了。 当我检查我的代码时,出现了这个错误:

Exception: Service Spreadsheets timed out while accessing document with id XXX

这是我的 function 来获取/获取工作表中的所有数据:

function GetAllData(){
  var mySpreadsheet = SpreadsheetApp.openById("xxxxxxxxxxxxxxxxxx").getSheetByName("Sheet1");
  var Cell = mySpreadsheet.getRange("A3:AB"+ raw_live.getLastRow());
  var Cell_contents = Cell.getValues();
  return Cell_contents;
}

这是我的 function 以按名称查找数据:

function SearchAttributebyName(ID){
  var attribute = GetAllData(); 
  for (var row=0; row<attribute.length; row++) {
    if(attribute[row][0]==ID){ 
      return "xxxxxxx"
    }
  }
    return "xxxxx";
}

任何人都可以帮助我,我怎样才能在没有错误/期望的情况下获取数据?

您显示的代码看起来不错,虽然它可以改进一点,但我认为这对您描述的性能问题没有帮助。

很可能性能不佳是由电子表格而不是脚本引起的。 要提高电子表格性能,请参阅这些优化技巧

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM