如何检测用户变更表? [英] How to detect user changing sheet?
本文介绍了如何检测用户变更表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在打开电子表格中的特定工作表期间如何检测和触发自定义操作?
How to detect and trigger custom action during opening specific sheet in spreadsheet?
我在 https://developers.google.com上找不到适当的功能/apps-script/guides/triggers/events
推荐答案
要按照Mogsdad的建议进行轮询,可以在补充工具栏(或任何UI元素)中使用此代码
To do polling as Mogsdad suggested you could use this code in your Sidebar (or any UI element)
$(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;
}
这篇关于如何检测用户变更表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文