0

我将这些脚本放入 Google 文档中,但它什么也没做。我在文档中看不到 UI。

function demoUI() {
var myapp = UiApp.createApplication().setTitle('An improved GUI');

var mygrid = myapp.createGrid(3, 2);
mygrid.setWidget(0, 0, myapp.createLabel('Name:'));
mygrid.setWidget(0, 1, myapp.createTextBox());
mygrid.setWidget(1, 0, myapp.createLabel('Age:'));
mygrid.setWidget(1, 1, myapp.createTextBox());
mygrid.setWidget(2, 0, myapp.createLabel('City'));
mygrid.setWidget(2, 1, myapp.createTextBox());

var mybutton = myapp.createButton('Press me');
var mypanel = myapp.createVerticalPanel();
mypanel.add(mygrid);
mypanel.add(mybutton);
myapp.add(mypanel);
return myapp;
}​
4

2 回答 2

0

您是否在 Google Doc 容器中操作?在这种情况下,显示 ui 的方法不同,您需要将它们放在侧边栏或对话框中,请在此处查看:https ://developers.google.com/apps-script/guides/docs#custom_menus_and_user_interfaces

于 2013-09-19T02:09:13.820 回答
0

你应该更换:

return myapp;

经过:

var ss = SpreadsheetApp.getActiveSpreadsheet();
    ss.show(myapp);

最后,你应该有:

function demoUI() {
  var myapp = UiApp.createApplication().setTitle('An improved GUI');

  var mygrid = myapp.createGrid(3, 2);
  mygrid.setWidget(0, 0, myapp.createLabel('Name:'));
  mygrid.setWidget(0, 1, myapp.createTextBox());
  mygrid.setWidget(1, 0, myapp.createLabel('Age:'));
  mygrid.setWidget(1, 1, myapp.createTextBox());
  mygrid.setWidget(2, 0, myapp.createLabel('City'));
  mygrid.setWidget(2, 1, myapp.createTextBox());

  var mybutton = myapp.createButton('Press me');
  var mypanel = myapp.createVerticalPanel();
  mypanel.add(mygrid);
  mypanel.add(mybutton);
  myapp.add(mypanel);


  var ss = SpreadsheetApp.getActiveSpreadsheet();
  ss.show(myapp);
 }
于 2014-06-29T05:19:51.593 回答