简体   繁体   English

从Google Apps脚本创建HTML页面

[英]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.

相关问题 使用Google Apps脚本从HTML页面上的JSON数据创建下拉列表 - Create dropdown from JSON data on HTML page using Google Apps Script Google Apps Script - 将带有样式的 HTML 转换为 PDF 并附加到电子邮件 - 从 HTML 创建 PDF blob - Google Apps Script - Convert HTML with styling to PDF and attach to an email - Create a PDF blob from HTML 将值从 HTML 传递到 Google Apps 脚本上的 Google 脚本? - Pass value from HTML to Google Script on Google Apps Script? 从Google Apps脚本网页上的HTML画布获取数据URI - Get a data URI from a HTML canvas on a Google Apps Script web page 在 Google Apps 脚本中从 HTML 创建 PDF 并包含图像 - 图像未显示 - Create PDF from HTML in Google Apps Script and include images - Images not showing up 没有页面刷新的Google Apps脚本HTML表单 - Google Apps Script Html Form Without Page Refresh 在链接到Google Apps脚本中的另一个HTML页面时传递参数 - Passing parameters while Linking to another html page in google apps script 创建动态HTML文件并在Google Apps脚本中执行 - create a dynamic html file and execute it in google apps script 将 .gs(Google Apps 脚本)中的数据共享到<script> variable in html - Share data from .gs (Google Apps Script) to <script> variable in html 从Google Apps脚本HTML模板渲染HTML - render html from Google apps script html template
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM