如何在电子表格中打开特定工作表时检测并触发自定义操作?
我在 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/