function openDialog()设置宽度和设置高度Google Spreadsheets

时间:2016-09-22 12:02:20

标签: javascript html css google-apps-script google-sheets

我需要设置dialog in a Google Spreadsheet的宽度。

到目前为止,我的代码是:

// Use this code for Google Docs, Forms, or new Sheets.
function onOpen() {
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
      .createMenu('Cadastro')
      .addItem('Open', 'openDialog')
      .addToUi();
}

function openDialog() {
  var html = HtmlService.createHtmlOutputFromFile('index');
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
      .showModalDialog(html, 'Dialog title');
}`enter code here`

1 个答案:

答案 0 :(得分:0)

这将设置您的身高和宽度。

function openDialog() {
  var html = HtmlService.createHtmlOutputFromFile('index')
  .setHeight(100)
  .setWidth(100);
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp
  .showModalDialog(html, 'Dialog title')
  }//`enter code here`

当然,您还需要将index.html文件添加到脚本编辑器中,如:

Hello, world! <input type="button" value="Close" onclick="google.script.host.close()" />