以下是一个示例代码,演示如何在Google Apps Script中使用模态对话框显示和从绑定脚本到库的google.script.run。
HTML文件(dialog.html):
模态对话框
Google Apps Script文件(Code.gs):
function showDialog() {
var htmlOutput = HtmlService.createHtmlOutputFromFile('dialog.html')
.setWidth(400)
.setHeight(300);
SpreadsheetApp.getUi().showModalDialog(htmlOutput, '模态对话框');
}
function getData() {
return '这是从绑定脚本到库中返回的数据';
}
要使用以上代码,您需要按照以下步骤进行操作:
showDialog
函数,以显示模态对话框。getData
函数,并显示返回的数据。这是一个简单的示例,演示了如何在模态对话框中使用google.script.run
从绑定脚本到库中调用函数并显示返回的数据。您可以根据自己的需求进行修改和扩展。