繁体   English   中英

通过 Google Apps 脚本将电子表格发布为网络应用

[英]Publish a spreadsheet as a web app through Google Apps Script

我正在尝试通过嵌入在另一个电子表格中的脚本代码将电子表格发布为 Web 应用程序。

  • 我想复制电子表格
  • 我想将复制的电子表格发布为网络应用程序
  • 我想检索刚刚创建的 web 应用程序界面的公共 url
  • 我想获取嵌入在复制的电子表格中的 doGet() 函数的结果

感谢 Tanaike 的帮助,我写了这段代码:

 // Copies the spreadsheet
 var repliesFile = responseTemplate.makeCopy('risposte', newFolder);

 // Publish the spreadsheet (Drive Api is enabled)
 Drive.Revisions.update({published: true, publishedOutsideDomain: true, publishAuto: true}, repliesFile.getId(), 1);
 var webAppUrl = "https://docs.google.com/spreadsheet/pub?key=" + repliesFile.getId();

问题:使用 webAppUrl 我可以看到已发布的电子表格,但我想要的是复制电子表格中 doGet() 函数返回的 html。 简而言之,如果我通过“发布 -> 部署为 Web 应用程序”发布 Web 应用程序,我会得到相同的界面。 有没有办法得到它? 附上几张图片(不要介意html模板中的模板变量)。

感谢您为我提供的所有帮助!

复制的电子表格嵌入代码中的 doGet() 函数 我通过“发布 -> 部署为 Web 应用程序”获得的 Web 应用程序界面 我的代码得到了什么

要获取 WebApp 的 URL,您可以使用ScriptApp.getService().getUrl()

请注意,此方法仅在您将脚本部署为 Web 应用程序后才有效。 并且 WebApp 仅在包含doGet()函数时才能按预期工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM