使用:
Google表格(新)
目标:
在电子表格中,显示从HTML创建的模式对话框,然后运行一个函数,然后自动关闭该HTML提示.对话框一直保持到函数完成执行,然后自动消失.这个过程必须每3个小时重复一次,脚本需要像我一样运行(因为我有其他用户没有的编辑权限),所以简单的触发器可能不起作用(我读过你必须创建一个可安装的触发器)如果你希望函数像你一样运行而不是当前用户在给定时间运行的那个人)
是)我有的:
我的代码
这是我的第一个剧本,所以请不要太反感!
Magic_Telling
从HTML文件创建模态对话框
function Magic_Telling() {
var UI = SpreadsheetApp.getUi();
var newline = '\n'
// Display a modal dialog box with custom HtmlService content.
var htmlOutput = HtmlService.createHtmlOutputFromFile('PromptStyling')
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
.setWidth(300)
.setHeight(100);
UI.showModalDialog(htmlOutput, ' ');
}
Run Code Online (Sandbox Code Playgroud)
Prompt_Styling
用于样式提示的HTML文件+运行将处理行的函数All_In的脚本
<html>
<head>
// some irrelevant stuff here
</head>
<script>
window.onload = function() {
google.script.run
.withSuccessHandler(closeDialog)
.All_In();
};
window.closeDialog = function() {
google.script.host.close();
};
</script>
</html>
Run Code Online (Sandbox Code Playgroud)
All_In
函数用于处理行
function All_In() {
UnlockRowBlocks();
UnhideRowBlocks();
LockRowBlocks();
HideRowBlocks();
} …Run Code Online (Sandbox Code Playgroud)