[英]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.