2

I displaying What I want to do with similar to this tutorial but instead of using UI Services to display the table, I would like to use HTML Services. Someone from this question mentioned that you could use Templated HTML to display Spreadsheet data in html. Could anyone elaborated on this topic? A simple example like this would very helpful because I'd like to see a demonstration on it works.

Thank you!

4

1 回答 1

5

有一个使用模板化 HTML 从文档中可用的电子表格数据显示表格的简单示例,请点击此处

我已经发布了一个运行副本,使用来自 Waqar 教程的相同数据,以便于比较。源电子表格在这里,脚本也是。(编辑:下面还提供了脚本。)

代码.gs

// All code in this script is copied from
// https://developers.google.com/apps-script/guides/html-service-templates

function doGet() {
  return HtmlService
      .createTemplateFromFile('index')
      .evaluate();
}

function getData() {
  return SpreadsheetApp
      .openById('0AvF9FEyqXFxAdEplRHp5dGc4Q1E3OXMyV2s4RktiQWc')
      .getDataRange()
      .getValues();
}

索引.html

<? var data = getData(); ?>
<table border='1px solid black'>
  <? for (var i = 0; i < data.length; i++) { ?>
    <tr>
      <? for (var j = 0; j < data[i].length; j++) { ?>
        <td><?= data[i][j] ?></td>
      <? } ?>
    </tr>
  <? } ?>
</table>
于 2013-05-21T17:30:28.740 回答