2016-09-22 123 views
-2

我需要設置一個dialog in a Google Spreadsheet的寬度。函數openDialog()設置寬度和設置高度Google Spreadsheets

到目前爲止,我的代碼是:

// 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` 

回答

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()" /> 
+0

謝謝!完美工作;) –

+0

如果這對你有用,你能否批准答案?謝謝。 –