简体   繁体   English

每次打开电子表格时停止重新计算自定义函数?

[英]Stop a custom function from recalculating every time the spreadsheet is open?

I have a custom function that uses fetch to save some information to a spreadsheet.我有一个自定义函数,它使用 fetch 将一些信息保存到电子表格中。 The problem is, it's meant to be used many times on the spreadsheet, fetching from various pages.问题是,它应该在电子表格上多次使用,从各个页面获取。 As the amount of uses increases, needlessly re-fetching information every time the spreadsheet opens will become more and more of a problem.随着使用量的增加,每次打开电子表格时不必要地重新获取信息将成为越来越大的问题。

Is there any way to avoid this default behavior?有什么办法可以避免这种默认行为? I still want it to recalculate every time the cell is edited, even if the parameters are exactly the same.我仍然希望它在每次编辑单元格时重新计算,即使参数完全相同。 Is there perhaps a way to tell if it's a manual edit vs. automatic recalculation, or simply disable the behavior entirely?有没有办法判断它是手动编辑还是自动重新计算,或者只是完全禁用该行为?

Is there perhaps a way to tell if it's a manual edit vs. automatic recalculation, or simply disable the behavior entirely?有没有办法判断它是手动编辑还是自动重新计算,或者只是完全禁用该行为?

No and no.没有也没有。

One of possible workarounds is to have a "switch" in some cell of the spreadsheet: say, if cell A1 has "Update" then custom functions recalculate normally;一种可能的解决方法是在电子表格的某些单元格中设置“开关”:例如,如果单元格 A1 具有“更新”,则自定义函数将正常重新计算; otherwise they do nothing.否则他们什么都不做。 That cell (A1) can have data validation with dropdown, for easy switching between states.该单元格 (A1) 可以通过下拉列表进行数据验证,以便在状态之间轻松切换。 The custom functions would be modifying to include the following:自定义函数将被修改为包括以下内容:

function customFunction(...) {
  var currentStatus = SpreadsheetApp.getActiveSheet().getRange("A1").getValue();
  if (currentStatus != "Update") {
    return; 
  }
  // the rest of function

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

相关问题 重新计算电子表格副本中的公式 - Recalculating formulas in a copy of a spreadsheet 如何从电子表格自定义功能访问ScriptDB? - How to Access ScriptDB from Spreadsheet Custom Function? 从自定义菜单在客户端浏览器中打开其他电子表格 - Open a different spreadsheet in the client browser from a custom menu 尝试打开另一个电子表格时来自自定义函数的错误消息。 “您无权执行该操作。” - Error msg from custom function when trying to open another spreadsheet. "You do not have permission to perform that action." 如何从电子表格公式调用库函数作为自定义函数? - How to call library function as custom function from spreadsheet formula? 用于在电子表格中添加 csv 的 Google 电子表格自定义函数 - Google Spreadsheet custom function to add csv in spreadsheet 从 Google 电子表格自定义函数进行的 Ajax 调用 - Ajax calls made from Google Spreadsheet Custom Function 在Google电子表格中使用自定义功能? - Using a Custom Function in a Google Spreadsheet? 自定义电子表格功能中的“未定义Google” - 'google is not defined' in custom spreadsheet function 在Time Book Application教程中打开电子表格失败 - Open spreadsheet fails in Time Book Application tutorial
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM