Google Scripts Error: "No HTML file named index.html was found. (line 2, file "Code", project "Version 1")"

Google Scripts Error: "No HTML file named index.html was found. (line 2, file "Code", project "Version 1")"

当我将 Google Scripts 脚本部署为 Web 应用程序时,一切都按我预期的方式运行。但是,将脚本插入我的 Google 站点页面后,出现错误 "No HTML file named index.html was found. (line 2, file "Code", project "Version 1")"

我不明白这是怎么回事,因为我有一个索引,当我将它部署为 Web 应用程序时,它似乎可以很好地处理脚本。这是我的代码:

code.gs:

function doGet() {

  return HtmlService.createHtmlOutputFromFile('index');

  var data = Charts.newDataTable()
      .addColumn(Charts.ColumnType.STRING, "Stage")
      .addColumn(Charts.ColumnType.NUMBER, "Central - Q1")
      .addColumn(Charts.ColumnType.NUMBER, "Northeast/Canada - Q1")
      .addColumn(Charts.ColumnType.NUMBER, "NY/NJ/Financials - Q1")
      .addColumn(Charts.ColumnType.NUMBER, "Southeast/SP - Q1")
      .addColumn(Charts.ColumnType.NUMBER, "West - Q1")
      .addColumn(Charts.ColumnType.NUMBER, "APAC - Q1")
      .addColumn(Charts.ColumnType.NUMBER, "EMEA - Q1")
      .addColumn(Charts.ColumnType.NUMBER, "Japan - Q1")
      .addColumn(Charts.ColumnType.NUMBER, "Central - Q2")
      .addColumn(Charts.ColumnType.NUMBER, "Northeast/Canada - Q2")
      .addColumn(Charts.ColumnType.NUMBER, "NY/NJ/Financials - Q2")
      .addColumn(Charts.ColumnType.NUMBER, "Southeast/SP - Q2")
      .addColumn(Charts.ColumnType.NUMBER, "West - Q2")
      .addColumn(Charts.ColumnType.NUMBER, "APAC - Q2")
      .addColumn(Charts.ColumnType.NUMBER, "EMEA - Q2") 
      .addColumn(Charts.ColumnType.NUMBER, "Japan - Q2")
      .addRow(["Needs Arista's Help to Deploy", x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x])
      .addRow(["Customer in Production", x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x])
      .addRow(["Unlikely to Deploy", x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x])
      .addRow(["Plans to Deploy Independently", x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x])
      .addRow(["Wrong Territory", 1x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x])
      .addRow(["Blank", x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x])
      .build();

  var quarterFilter = Charts.newCategoryFilter()
      .setFilterColumnLabel("Stage")
      .setAllowTyping(true)
      .setAllowMultiple(true)
      .build();

  var territoryFilter = Charts.newCategoryFilter()
      .setFilterColumnLabel("Central - Q1")
      .setAllowTyping(true)
      .setAllowMultiple(true)
      .build();

  var columnChart = Charts.newColumnChart()
      .setDataViewDefinition(Charts.newDataViewDefinition()
                            .setColumns([0, 1, 2, 3, 4,5,6,7,8,9,10,11,12,13,14,15,16]))
      .setDimensions(1000, 800)
      .build();

  var tableChart = Charts.newTableChart()
      .setDimensions(1200, 300)
      .build();

  var dashboard = Charts.newDashboardPanel()
      .setDataTable(data)
      .bind([quarterFilter, territoryFilter], [columnChart, tableChart])
      .build();

  var uiApp = UiApp.createApplication();

  dashboard.add(uiApp.createVerticalPanel()
                .add(uiApp.createHorizontalPanel()
                    .add(quarterFilter).add(territoryFilter)
                    .setSpacing(70))
                .add(uiApp.createVerticalPanel()
                    .add(columnChart).add(tableChart)
                    .setSpacing(50)));

  uiApp.add(dashboard);
  return uiApp;
}

index.html:

   <html>
      <head>
        <meta name="gwt:property" content="locale=en">
        <style type="text/css">
            html,body {margin: 0; padding: 0; height: 100%;}
                .loading-text{background: url(gwt/images/spin-wait.gif) no-repeat; font-size: 16px; font-weight: bold; margin: 16px 0 16px 40px; padding-left: 22px;}
                .loading-box {background-color: white; border: 1px solid #ACACAC; border-bottom-color: #999; box-shadow: 0 4px 16px rgba(0,0,0,0.2); margin-top: -25px; margin-left: -100px; padding: auto; position: absolute; top: 50%; left: 50%; width: 200px; height: 50px; z-index: 16777272;}
                .loading-glass-panel {-ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=30 );filter: alpha(opacity = 30); opacity: 0.3; background-color: #999; display: block; position: absolute; width: 100%; height: 100%; z-index: 16777271;}
        </style>
        <script type="text/javascript">
            var startTime = new Date().getTime();
            var tzPointsJson = "\x5b1109635200000,1128902400000,1130657000000,1143333000000,1143806400000,1145000000000,1146380000000,1152489600000,1159800000000,1159500000000,1162095000000,1162075000000,1162105500000\x5d";
            var libId = "Mo7m4kwokfCocmLBpFogl0-o1H6hGQoPE";
            var payload = "\x7b\x22types\x22:\x7b\x22u1647587496418\x22:\x22VerticalPanel\x22,\x22u1647587496419\x22:\x22HorizontalPanel\x22,\x22u1647587496420\x22:\x22VerticalPanel\x22,\x22u1647587496412\x22:\x22Control\x22,\x22u1647587496414\x22:\x22Chart\x22,\x22u1647587496413\x22:\x22Control\x22,\x22u1647587496416\x22:\x22DashboardPanel\x22,\x22u1647587496415\x22:\x22Chart\x22\x7d,\x22libId\x22:\x22Mo7m4kwokfCocmLBpFogl0-o1H6hGQoPE\x22,\x22id\x22:\x22u1647587496417\x22,\x22title\x22:\x22\x22,\x22commands\x22:\x5b\x7b\x22args\x22:\x5b\x5d,\x22cmd\x22:\x22VERTICALPANEL\x22,\x22id\x22:\x22u1647587496418\x22\x7d,\x7b\x22args\x22:\x5b\x5d,\x22cmd\x22:\x22HORIZONTALPANEL\x22,\x22id\x22:\x22u1647587496419\x22\x7d,\x7b\x22args\x22:\x5b\x22CategoryFilter\x22,null,\x7b\x22ui\x22:\x7b\x22allowMultiple\x22:true,\x22allowTyping\x22:true\x7d,\x22filterColumnLabel\x22:\x22Stage\x22\x7d\x5d,\x22cmd\x22:\x22GVIZCONTROL\x22,\x22id\x22:\x22u1647587496412\x22\x7d,\x7b\x22args\x22:\x5b\x7b\x22id\x22:\x22u1647587496412\x22\x7d\x5d,\x22cmd\x22:\x22ADD\x22,\x22id\x22:\x22u1647587496419\x22\x7d,\x7b\x22args\x22:\x5b\x22CategoryFilter\x22,null,\x7b\x22ui\x22:\x7b\x22allowMultiple\x22:true,\x22allowTyping\x22:true\x7d,\x22filterColumnLabel\x22:\x22Central - Q1\x22\x7d\x5d,\x22cmd\x22:\x22GVIZCONTROL\x22,\x22id\x22:\x22u1647587496413\x22\x7d,\x7b\x22args\x22:\x5b\x7b\x22id\x22:\x22u1647587496413\x22\x7d\x5d,\x22cmd\x22:\x22ADD\x22,\x22id\x22:\x22u1647587496419\x22\x7d,\x7b\x22args\x22:\x5b70\x5d,\x22cmd\x22:\x22SETSPACING\x22,\x22id\x22:\x22u1647587496419\x22\x7d,\x7b\x22args\x22:\x5b\x7b\x22id\x22:\x22u1647587496419\x22\x7d\x5d,\x22cmd\x22:\x22ADD\x22,\x22id\x22:\x22u1647587496418\x22\x7d,\x7b\x22args\x22:\x5b\x5d,\x22cmd\x22:\x22VERTICALPANEL\x22,\x22id\x22:\x22u1647587496420\x22\x7d,\x7b\x22args\x22:\x5b\x22ColumnChart\x22,null,null,\x7b\x22width\x22:1000,\x22height\x22:800\x7d,\x7b\x22columns\x22:\x5b0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16\x5d\x7d\x5d,\x22cmd\x22:\x22CHART\x22,\x22id\x22:\x22u1647587496414\x22\x7d,\x7b\x22args\x22:\x5b\x7b\x22id\x22:\x22u1647587496414\x22\x7d\x5d,\x22cmd\x22:\x22ADD\x22,\x22id\x22:\x22u1647587496420\x22\x7d,\x7b\x22args\x22:\x5b\x22Table\x22,null,null,\x7b\x22width\x22:1200,\x22height\x22:300\x7d,\x7b\x7d\x5d,\x22cmd\x22:\x22CHART\x22,\x22id\x22:\x22u1647587496415\x22\x7d,\x7b\x22args\x22:\x5b\x7b\x22id\x22:\x22u1647587496415\x22\x7d\x5d,\x22cmd\x22:\x22ADD\x22,\x22id\x22:\x22u1647587496420\x22\x7d,\x7b\x22args\x22:\x5b50\x5d,\x22cmd\x22:\x22SETSPACING\x22,\x22id\x22:\x22u1647587496420\x22\x7d,\x7b\x22args\x22:\x5b\x7b\x22id\x22:\x22u1647587496420\x22\x7d\x5d,\x22cmd\x22:\x22ADD\x22,\x22id\x22:\x22u1647587496418\x22\x7d,\x7b\x22args\x22:\x5b\x7b\x22rows\x22:\x5b\x7b\x22c\x22:\x5b\x7b\x22v\x22:\x22Needs Arista\u0027s Help to Deploy\x22\x7d,\x7b\x22v\x22:10\x7d,\x7b\x22v\x22:4\x7d,\x7b\x22v\x22:12\x7d,\x7b\x22v\x22:4\x7d,\x7b\x22v\x22:11\x7d,\x7b\x22v\x22:16\x7d,\x7b\x22v\x22:22\x7d,\x7b\x22v\x22:2\x7d,\x7b\x22v\x22:10\x7d,\x7b\x22v\x22:5\x7d,\x7b\x22v\x22:14\x7d,\x7b\x22v\x22:9\x7d,\x7b\x22v\x22:11\x7d,\x7b\x22v\x22:19\x7d,\x7b\x22v\x22:21\x7d,\x7b\x22v\x22:1\x7d\x5d\x7d,\x7b\x22c\x22:\x5b\x7b\x22v\x22:\x22Customer in Production\x22\x7d,\x7b\x22v\x22:14\x7d,\x7b\x22v\x22:6\x7d,\x7b\x22v\x22:7\x7d,\x7b\x22v\x22:7\x7d,\x7b\x22v\x22:8\x7d,\x7b\x22v\x22:6\x7d,\x7b\x22v\x22:14\x7d,\x7b\x22v\x22:1\x7d,\x7b\x22v\x22:15\x7d,\x7b\x22v\x22:7\x7d,\x7b\x22v\x22:7\x7d,\x7b\x22v\x22:7\x7d,\x7b\x22v\x22:14\x7d,\x7b\x22v\x22:7\x7d,\x7b\x22v\x22:15\x7d,\x7b\x22v\x22:1\x7d\x5d\x7d,\x7b\x22c\x22:\x5b\x7b\x22v\x22:\x22Unlikely to Deploy\x22\x7d,\x7b\x22v\x22:24\x7d,\x7b\x22v\x22:12\x7d,\x7b\x22v\x22:13\x7d,\x7b\x22v\x22:12\x7d,\x7b\x22v\x22:26\x7d,\x7b\x22v\x22:18\x7d,\x7b\x22v\x22:20\x7d,\x7b\x22v\x22:4\x7d,\x7b\x22v\x22:26\x7d,\x7b\x22v\x22:14\x7d,\x7b\x22v\x22:14\x7d,\x7b\x22v\x22:12\x7d,\x7b\x22v\x22:31\x7d,\x7b\x22v\x22:19\x7d,\x7b\x22v\x22:23\x7d,\x7b\x22v\x22:6\x7d\x5d\x7d,\x7b\x22c\x22:\x5b\x7b\x22v\x22:\x22Plans to Deploy Independently\x22\x7d,\x7b\x22v\x22:4\x7d,\x7b\x22v\x22:0\x7d,\x7b\x22v\x22:1\x7d,\x7b\x22v\x22:0\x7d,\x7b\x22v\x22:5\x7d,\x7b\x22v\x22:0\x7d,\x7b\x22v\x22:6\x7d,\x7b\x22v\x22:2\x7d,\x7b\x22v\x22:5\x7d,\x7b\x22v\x22:2\x7d,\x7b\x22v\x22:1\x7d,\x7b\x22v\x22:0\x7d,\x7b\x22v\x22:7\x7d,\x7b\x22v\x22:0\x7d,\x7b\x22v\x22:6\x7d,\x7b\x22v\x22:1\x7d\x5d\x7d,\x7b\x22c\x22:\x5b\x7b\x22v\x22:\x22Wrong Territory\x22\x7d,\x7b\x22v\x22:11\x7d,\x7b\x22v\x22:1\x7d,\x7b\x22v\x22:14\x7d,\x7b\x22v\x22:3\x7d,\x7b\x22v\x22:2\x7d,\x7b\x22v\x22:9\x7d,\x7b\x22v\x22:0\x7d,\x7b\x22v\x22:0\x7d,\x7b\x22v\x22:4\x7d,\x7b\x22v\x22:0\x7d,\x7b\x22v\x22:0\x7d,\x7b\x22v\x22:0\x7d,\x7b\x22v\x22:1\x7d,\x7b\x22v\x22:0\x7d,\x7b\x22v\x22:0\x7d,\x7b\x22v\x22:0\x7d\x5d\x7d,\x7b\x22c\x22:\x5b\x7b\x22v\x22:\x22Blank\x22\x7d,\x7b\x22v\x22:0\x7d,\x7b\x22v\x22:0\x7d,\x7b\x22v\x22:2\x7d,\x7b\x22v\x22:0\x7d,\x7b\x22v\x22:50\x7d,\x7b\x22v\x22:0\x7d,\x7b\x22v\x22:70\x7d,\x7b\x22v\x22:0\x7d,\x7b\x22v\x22:14\x7d,\x7b\x22v\x22:0\x7d,\x7b\x22v\x22:8\x7d,\x7b\x22v\x22:10\x7d,\x7b\x22v\x22:54\x7d,\x7b\x22v\x22:12\x7d,\x7b\x22v\x22:84\x7d,\x7b\x22v\x22:0\x7d\x5d\x7d\x5d,\x22cols\x22:\x5b\x7b\x22id\x22:\x220\x22,\x22label\x22:\x22Stage\x22,\x22type\x22:\x22string\x22\x7d,\x7b\x22id\x22:\x221\x22,\x22label\x22:\x22Central - Q1\x22,\x22type\x22:\x22number\x22\x7d,\x7b\x22id\x22:\x222\x22,\x22label\x22:\x22Northeast\/Canada - Q1\x22,\x22type\x22:\x22number\x22\x7d,\x7b\x22id\x22:\x223\x22,\x22label\x22:\x22NY\/NJ\/Financials - Q1\x22,\x22type\x22:\x22number\x22\x7d,\x7b\x22id\x22:\x224\x22,\x22label\x22:\x22Southeast\/SP - Q1\x22,\x22type\x22:\x22number\x22\x7d,\x7b\x22id\x22:\x225\x22,\x22label\x22:\x22West - Q1\x22,\x22type\x22:\x22number\x22\x7d,\x7b\x22id\x22:\x226\x22,\x22label\x22:\x22APAC - Q1\x22,\x22type\x22:\x22number\x22\x7d,\x7b\x22id\x22:\x227\x22,\x22label\x22:\x22EMEA - Q1\x22,\x22type\x22:\x22number\x22\x7d,\x7b\x22id\x22:\x228\x22,\x22label\x22:\x22Japan - Q1\x22,\x22type\x22:\x22number\x22\x7d,\x7b\x22id\x22:\x229\x22,\x22label\x22:\x22Central - Q2\x22,\x22type\x22:\x22number\x22\x7d,\x7b\x22id\x22:\x2210\x22,\x22label\x22:\x22Northeast\/Canada - Q2\x22,\x22type\x22:\x22number\x22\x7d,\x7b\x22id\x22:\x2211\x22,\x22label\x22:\x22NY\/NJ\/Financials - Q2\x22,\x22type\x22:\x22number\x22\x7d,\x7b\x22id\x22:\x2212\x22,\x22label\x22:\x22Southeast\/SP - Q2\x22,\x22type\x22:\x22number\x22\x7d,\x7b\x22id\x22:\x2213\x22,\x22label\x22:\x22West - Q2\x22,\x22type\x22:\x22number\x22\x7d,\x7b\x22id\x22:\x2214\x22,\x22label\x22:\x22APAC - Q2\x22,\x22type\x22:\x22number\x22\x7d,\x7b\x22id\x22:\x2215\x22,\x22label\x22:\x22EMEA - Q2\x22,\x22type\x22:\x22number\x22\x7d,\x7b\x22id\x22:\x2216\x22,\x22label\x22:\x22Japan - Q2\x22,\x22type\x22:\x22number\x22\x7d\x5d\x7d,\x5b\x7b\x22charts\x22:\x5b\x22u1647587496414\x22,\x22u1647587496415\x22\x5d,\x22controls\x22:\x5b\x22u1647587496412\x22,\x22u1647587496413\x22\x5d\x7d\x5d\x5d,\x22cmd\x22:\x22GVIZD

ASHBOARDPANEL\x22,\x22id\x22:\x22u1647587496416\x22\x7d,\x7b\x22args\x22:\x5b\x7b\x22id\x22:\x22u1647587496418\x22\x7d\x5d,\x22cmd\x22:\x22ADD\x22,\x22id\x22:\x22u1647587496416\x22\x7d,\x7b\x22args\x22:\x5b\x7b\x22id\x22:\x22u1647587496416\x22\x7d\x5d,\x22cmd\x22:\x22ADD\x22,\x22id\x22:\x22u1647587496417\x22\x7d\x5d,\x22sMode\x22:false\x7d";
        var _tok = "AJuLMu1HSeeMwjZJTVoQWkK6ufvP_SgK-A:1501770451378";
        var serviceId = "AKfycbzmmtjlnXRuyfvRMQLi5Xc-Twn2J3HnvCW6jkOM6LBW";
        var _sd =  false ;
        var _aurg =  true ;
        var _ea =  false ;
        var _up = '\/a\/macros\/arista.com\/s\/AKfycbzmmtjlnXRuyfvRMQLi5Xc-Twn2J3HnvCW6jkOM6LBW';
        var standardsMode =  false ;
        var _MF = {"11":"https://drive.google.com/drive/search?q\u003dtype:script","13":"https://script.google.com/macros/srvStatic/rpc_relay.html","14":"https://docs.google.com/picker","15":"becca@arista.com","16":"https://script.google.com/a/macros/arista.com","18":"arista.com","19":"becca@arista.com","0":true,"1":false,"5":true,"8":30000,"9":0,"20":"AJuLMu1HSeeMwjZJTVoQWkK6ufvP_SgK-A:1501770451378","10":"https://console.cloud.google.com"};
    </script>
    <script type='text/javascript' src='gwt/googleappsscripts_userapp.nocache.js'>
    </script>
    <script type='text/javascript' src='//www.google.com/jsapi'>
    </script>
    <script type='text/javascript'>
        google.load('visualization', '1', {'callback': function() {}, 'packages':['corechart', 'controls', 'annotatedtimeline']});
    </script>
  </head>
  <body>
    <div class="loading-glass-panel" id="loading-glass-panel">
    </div>
      <div class="loading-box" id="loading-box">
      <div class="loading-text" id="loading-text">Loading...
    </div>
    </div>
  </body>
</html>

您对应用程序进行更改后是否更新了项目版本?在开发中,如果您使用 /dev 端点,它将始终显示应用程序的最新版本。当您 link /exec 端点时,它将指向当前项目版本。

Deploy as web app 对话框中通过 select 项目版本下拉创建项目的新版本。任何时候您对脚本进行更改时都需要执行此操作。

索引 html 文件必须在 Google 脚本项目中。 它不是 .gscript 文件旁边的 Index.html 文件。

所以你创建它是在 "Google Apps Scripts" 应用程序中你选择菜单项文件和 "New" => "HTML File".

您指定不带扩展名的文件名:"Index" 并注意区分大小写(因此如果您的文件是 "Index",则脚本中没有 "index")。

对我来说,问题是显然对 HTML 文件的引用区分大小写。因此请确保您的参考资料和文件名正确无误。

我的错误是:"Exception: No HTML file named javaScript was found. (line 33)"
解决方案:我将文件名从 javascript.html 更改为 javaScript.html。然后不要忘记制作一个新的项目版本,如上面答案中描述的Spencer,否则将无法运行!