Google apps script 在Google应用程序脚本中将变量推送到模板时出错

Google apps script 在Google应用程序脚本中将变量推送到模板时出错,google-apps-script,Google Apps Script,我试图将一个数组对象推送到HTMLService生成的模板中,以便填充一个下拉框 我的函数showSidebar在onOpen函数中调用 显示边栏 /** * Opens a sidebar in the document containing the add-on's user interface. */ function showSidebar() { var ui = HtmlService.createHtmlOutputFromFile('Sidebar') .se

我试图将一个数组对象推送到HTMLService生成的模板中,以便填充一个下拉框

我的函数showSidebar在onOpen函数中调用

显示边栏

/**
 * Opens a sidebar in the document containing the add-on's user interface.
 */
function showSidebar() {
  var ui = HtmlService.createHtmlOutputFromFile('Sidebar')
      .setTitle('Generate Reports');
  SpreadsheetApp.getUi().showSidebar(ui);
}
HTML文件Sidebar.HTML的内容是

<div class="sidebar branding-below">
  <form>
    <div class="block col-contain">
      <div class="block form-group">
         <label for="client-dd"><b>Client Name</b></label><br />
         <select id="client-dd" class="width-100">
         <? var data = getUniqueCustomers();
            for (var i = 0; i < data.length; i++) 
            { 
               var val = data[i]; 
               var v = val[0]; ?>
               <option value='<?!= v ?>'>
                  <?!=v ?>
               </option>
         <? } ?>
         </select>
      </div>
    </div>
  </form>
</div>
然而,出于某种原因,我在侧栏中看到了以下内容


有什么想法吗?

您正在尝试使用模板化HTML-为此,您需要使用HtmlService.createTemplateFromFile方法,而不是.createHtmlOutFromFile

function getUniqueCustomers(){
  var sheet = SpreadsheetApp.getActiveSpreadsheet();
  var rangeVals = sheet.getRange("E2:E");
  var x = ArrayLib.unique(rangeVals.getValues());
  return x;
}