Google Sheets App Scripts: Show and Close Sidebar

July 18, 2019
function showSidebar() {
  var authorizationUrl = "...";
  var template = HtmlService.createTemplate(
    'Click <a href="<?= authorizationUrl ?>" target="_blank">Authorize</a>.');
  template.authorizationUrl = authorizationUrl;
  var page = template.evaluate();
  SpreadsheetApp.getUi().showSidebar(page);
}

function closeSidebar() {
  var html = HtmlService.createHtmlOutput("<script>google.script.host.close();</script>");
  SpreadsheetApp.getUi().showSidebar(html);
}
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.