电子表格的“ HtmlService”中的“ getActiveApplication()”是否具有相同的属性?

时间:2019-11-02 18:07:45

标签: google-apps-script google-sheets

此问题与Google Spreadsheet中的“警告:UI服务已于2014年12月11日弃用。要创建用户界面,请改用HTML服务”。然后让我不再使用此标记“ UiApp.getActiveApplication()。close()”和“ 返回UiApp.getActiveApplication()”)。这两个函数的/ code / script属性具有什么相同呢?实际上,至少我可以即兴编码和转换,从“ UiApp”更改写入标签的“ HtmlService”。就像我在下面提供给您的特别示例一样,我想将其全部转换为HtmlService标签的每一行:

注意:我必须为我的英语道歉。

function showListSheet() {
  var s = SpreadsheetApp;
  var ss = s.getActiveSpreadsheet();
  var sss = ss.getSheets();
  var app = UiApp.createApplication().setTitle("S h e e t L i s t . . .").setHeight(390).setWidth(200);
  var table = app.createFlexTable().setCellPadding(5).setCellSpacing(0); 
  var widgets = []; 
  for (var i = 0; i < sss.length; i++) { 
    var sheet_name = sss[i].getName(); 
    widgets[i] = app.createHTML(sheet_name).setId(sheet_name); 
    table.setWidget(i, 1, widgets[i]) 
  } 
  var panel = app.createSimplePanel(); 
  panel.add(table); 
  app.add(panel); 
  ss.show(app); 
}

1 个答案:

答案 0 :(得分:0)

TADAAA !!!阿罗哈..我想我已经解决了我自己的问题,但是我猜另一个问题又来了。 ftttt ...有人要帮助我!我只想让多个选定的行现在将其实现到我刚刚用HtmlService创建的表中。这是我编写的代码:

注意:写我英语的借口。

function showListSheet() {
  var s = SpreadsheetApp;
  var ss = s.getActiveSpreadsheet();
  var sss = ss.getSheets();
  var result = "<head><style type='text/css'>.gridview {display: inline-block; border-collapse: collapse; margin: 0px 4px 4px 0; box-shadow: 3px 3px 4px #bbb;} .gridview, .gridview td,  .gridview th {margin: 0; border:  1px solid #cccccc;} .gridview th {font-size: 1.1em; height: 25px; text-align: center; font-weight: normal; color: #F9F9F9; background: #337EB5;} .gridview th a, .gridview th a:link, .gridview th a:visited, .gridview th a:active {color: #F9F9F9; text-decoration: none;} .gridview th a:hover {text-decoration: underline;} .gridview tr {background: #F4F9FD;} .gridview tr:nth-child(odd)  {background-color: #F4F9FD;} .gridview tr:nth-child(even)  {background-color: #EDF5FC;} .gridview td  {font-weight: normal; text-align: left; vertical-align: top;} .gridview td {padding: 4px 0 5px 9px;} .gridview tfoot td {background-color: #EEEEEE;} .gridview tfoot td .page {color: #000000; font-weight: bold;} .gridview tr.subfoot, .gridview tr.subfoot td {background-color: #FFFFEC;} .gridview tr:hover td, .gridview tbody tr:hover td {background-color: #feb4cc; cursor: pointer; color: white;} .gridview .selected, .gridview tbody .selected {background-color: #E74C3C;  -webkit-animation: miniRainBow 20s infinite;  animation: miniRainBow 20s infinite; color: #fff;}</style></head><table border=1 class='gridview'>";
    for (var i = 0; i < sss.length; i++) {
        result += "<tr OnClick=\"this.id.attr('class', 'selected')\" id=\"tgt\">"
          result += "<td><input type='checkbox' onClick='return false;' readonly/></td><td>" + sss[i].getName() + "</td>";
      result += "</tr>";
    }
    result += "</table>";

  ss.show(HtmlService.createHtmlOutput(result)
    .setSandboxMode(HtmlService.SandboxMode.IFRAME)
    .setTitle("L i s t   O f   S h e e t   . . .")
    .setHeight(500)
    .setWidth(300));
}