简体   繁体   中英

Publish a spreadsheet as a web app through Google Apps Script

I am trying to publish a spreadsheet as a web app through the script code embedded in another spreadsheet.

  • I want to copy a spreadsheet
  • I want to publish the copied spreadsheet as a web app
  • I want to retrieve the public url of the web app interface just created
  • I want to get the result of the doGet() function embedded in the copied spreadsheet

Thanks to Tanaike's help I wrote this code:

 // 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();

Problem: using webAppUrl I can see the published spreadsheet but what I want is the html returned by the doGet() function in the copied spreadsheet. In a few words, the same interface I get if I publish the web app via 'Publish -> Deploy as Web App'. Is there a way to get it? A few images are attached (don't mind the template variables in the html template).

Thanks for all the help you can give me!

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

To obtain the URL of a WebApp you can use the method ScriptApp.getService().getUrl()

Note that this method will only work once you deployed the script as a Web App. And the WebApp will only work as intended if it contains a doGet() function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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