Google apps script 如何使用HtmlService创建到复制的Google驱动器文件的链接(按钮)?

Google apps script 如何使用HtmlService创建到复制的Google驱动器文件的链接(按钮)?,google-apps-script,Google Apps Script,当我这样做时: var file = DriveApp.createFile(pdf); 并添加“成功”屏幕: var html = HtmlService.createHtmlOutputFromFile('page') .setSandboxMode(HtmlService.SandboxMode.IFRAME) .setWidth(300) .setHeight(100); DocumentApp.getUi() .showModalDialog(html, 'Done!'); 我如

当我这样做时:

var file = DriveApp.createFile(pdf);
并添加“成功”屏幕:

var html = HtmlService.createHtmlOutputFromFile('page')
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
.setWidth(300)
.setHeight(100);
DocumentApp.getUi() 
.showModalDialog(html, 'Done!');
我如何在这个屏幕上获得一个链接到制作文件的按钮? 我可以使用:

file.getUrl()
我应该在html页面上添加什么代码

<input type="button" value="OK" onclick="???" />


欢迎使用任何指针。

我会尝试使用getid()

然后尝试以下方法:

Var fileIds=[];

//Logger.log(“https://drive.google.com/uc?export=download&id=“+fileid[i])您需要使用
.createTemplateFromFile()
。这将允许您将信息从脚本传递到模式对话框。在
code.gs
中,它看起来像这样:

var html = HtmlService.createTemplateFromFile("template");
//do not evaluate your html template, yet!

//get file url to pass to template
var fileUrl = file.getUrl();

//pass fileUrl to the html template as though it were a parameter of the
//html object
html.url = fileUrl;

//evaluate template and set features
var output = html.evaluate()
                 .setSandboxMode(HtmlService.SandboxMode.IFRAME)
                 .setWidth(300)
                 .setHeight(100);

DocumentApp.getUi().showModalDialog(output, 'Done!');
现在,在html模板文件中,使用检索文件的url以在自定义按钮中使用:

<a href="<?= url ?>" target="_blank"><button>Open file</button></a>


这将在新窗口中打开您的新文件。

选中此项,它可以帮助您在脚本中添加按钮。也许我的问题不太清楚。我需要知道的是如何在按钮中“存储”新创建文件的URL。该按钮由html制作,并使用HtmlService显示。这是谷歌文档,而不是电子表格。任何人