title: Dynamic google spreadsheet data to HTML
body: <p>Having problems with generating a spreadsheet into a HTML table.  Following this:  <a href="https://developers.google.com/apps-script/html_service" rel="nofollow">HTML Service- Apps scripts</a>.    It isn't clear to me how to define the variable <em>htmlOutput</em> or how to display/return it. Thanks for your thoughts.</p>
  
  <pre><code>function doGet() {
  var t = HtmlService.createTemplateFromFile('myTemplate');
  var htmlOutput =  t.evaluate();
  return htmlOutput;
  }
  </code></pre>
  
  <p>My HTML template 'myTemplate.html' is:</p>
  
  <pre><code>&lt;html&gt;
  &lt;table&gt;
  &lt;? var sheet = SpreadsheetApp.openById("ID").getSheetByName("Results-List");
   var lastRow = sheet.getLastRow();  
   var myRange = sheet.getRange("A2:G"+lastRow); 
   var data = myRange.getValues();
   for (var i = 0; i &lt; data.length; ++i) { ?&gt;
  &lt;tr&gt;
    &lt;? for  (var j = 0; j &lt; data[i].length; ++j) { ?&gt;
      &lt;td&gt;&lt;?= data[i][j]?&gt;&lt;/td&gt;
    &lt;? } ?&gt;
  &lt;/tr&gt;
  &lt;? } ?&gt;
  &lt;/table&gt;
  &lt;/html&gt;
  </code></pre>