gpt4 book ai didi

google-apps-script - 如何检测用户更改表?

转载 作者:行者123 更新时间:2023-12-02 21:02:12 24 4
gpt4 key购买 nike

如何在电子表格中打开特定工作表时检测并触发自定义操作?

我在 https://developers.google.com/apps-script/guides/triggers/events 中找不到正确的功能

最佳答案

要按照 Mogsdad 的建议进行轮询,您可以在侧边栏(或任何 UI 元素)中使用此代码

$(function() {
/**
* On document load, assign click handlers to each button and try to load the
* user's origin and destination language preferences if previously set.
*/
poll();
}

function poll(interval){
interval = interval || 2000;
setTimeout(function(){
google.script.run.withSuccessHandler(loadSheetName)
.withFailureHandler(showError).getSheetName();
poll();
}, interval);
};

function loadSheetName(sheetName) {
alert(sheetName);
}

function getSheetName() {
google.script.run.withSuccessHandler(loadSheetName)
.withFailureHandler(showError).getSheetName();
}

在你的 .gs 代码中

function getSheetName() {
var sheetName = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getName();
return sheetName;
}

关于google-apps-script - 如何检测用户更改表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37703309/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com