

For details, see the Google Developers Site Policies. Choose Dialog > Open to see theĮxcept as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License.

After that, the custom menu should appear within a few secondsĮvery time you open the file. Or reload the window for the Docs, Sheets, or Forms editor (which will close the Note that the first time you want to display this user interface, you must Var html = HtmlService.createHtmlOutputFromFile('Index') SpreadsheetApp.getUi() // Or DocumentApp or SlidesApp or FormApp. To open the interface, and the button in the HTML file invokes a specialĬode.gs // Use this code for Google Docs, Slides, Forms, or Sheets. These examples include a few extra features for convenience: the onOpen()įunction creates a custom menu that makes it easy Ui object for the active document, form, or ShowModalDialog()) or showSidebar() methods of the That opens the user interface must pass your HTML file as an Not need to save a version of your script or deploy it. Spreadsheet, or form does not need a doGet() function specifically, and you do Unlike a web app, a script that creates a user interface for a document, Modify it, not to a user who opens the form to respond.) (In Google Forms,Ĭustom user interfaces are only visible to an editor who opens the form to In Google Docs, Sheets, Slides, or Forms if your script isĬontainer-bound to the file. The HTML service can display a dialog or sidebar

Serve HTML as a Google Docs, Sheets, Slides, or Forms user interface Once that basic framework is in place, all you have to do isĪfter the script is deployed as a web app, you can also choose toĮmbed it in a Google Site. Return HtmlService.createHtmlOutputFromFile('Index') To create a web app with the HTML service, your code must include a doGet()įunction that tells the script how to serve the page. Your file can also include template scriptlets that are processed on the serverīefore the page is sent to the user - similar to PHP - as explained in the The page will be served as HTML5, although some advanced features of Within the HTML file, you can write most standard HTML, CSS, and client-side To add an HTML file to your Apps Script project, follow these steps: You can even use it to generate the body of an email. It is particularly usefulįor building web apps or adding custom user interfaces in Google Docs, Sheets,Īnd Forms. The HTML service lets you serve web pages thatĬan interact with server-side Apps Script functions.
