[英]create html page from google apps script
I am trying to create a 'dashboard' in Google Sheets that can be opened up in a separate window from a button in the sidebar. 我正在尝试在Google表格中创建一个“仪表板”,可以从侧边栏中的按钮在单独的窗口中打开该仪表板。 This dashboard ingests data from a google sheets script.
此信息中心从Google表格脚本中提取数据。 Currently I am struggling to create and serve this page other than to deploy it as a 'web-app'
目前,除了将其部署为“网络应用”之外,我正在努力创建和提供此页面
If I deploy this script as a web-app it creates a new window, with correct htmloutput from my file in the doGet() function, however this dashboard is linked to only the current document and will be the same for other users instead of re-generating the page for different sheets. 如果我将此脚本部署为Web应用程序,它将创建一个新窗口,并在doGet()函数中从我的文件中输出正确的html输出,但是此仪表板仅链接到当前文档,并且对于其他用户而言将是相同的,而不是-为不同的工作表生成页面。
Is there a way or work-around to create and serve a webpage, similar to methods such as showSidebar() or showModalDialog() in class UI. 有没有一种方法或变通方法来创建和提供网页,类似于类UI中的showSidebar()或showModalDialog()之类的方法。 I dont really want users to have to publish themselves because it is too much
我真的不希望用户不得不发布自己,因为它太多了
I use this function to return a specific HTML page using a Google web app: 我使用此功能通过Google网络应用返回特定的HTML页面:
function doGet(e) {
Logger.log( Utilities.jsonStringify(e) );
if (!e.parameter.page) {
// When no specific page requested, return "home page"
return HtmlService.createTemplateFromFile("index").evaluate().setTitle("Elkhart PD");
}
// else, use page parameter to pick an html file from the script
return HtmlService.createTemplateFromFile(e.parameter['page']).evaluate().setTitle(e.parameter['page']);
}
Start with a dashboard from the main page. 从主页上的仪表板开始。 Use anchor tags in
index.html
with their location as follows: 在
index.html
使用锚标签及其位置,如下所示:
https://script.google.com/a/macros/documentKey1234567/dev?page=extraPage1.html
(Title the page=
parameter with the html titles in the project.) (将
page=
参数与项目中的html标题一起命名。)
These pages are opened as a standalone HTML page, so you can call the appropriate data using the google.script.run.myFunction()
API. 这些页面将作为独立的HTML页面打开,因此您可以使用
google.script.run.myFunction()
API调用相应的数据。 The GAS on the backend can pull from any sheet you have access to to serve the appropriate dashboard. 后端的GAS可以从您有权访问的任何工作表中提取信息以提供相应的信息中心。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.