【发布时间】:2021-08-27 00:37:01
【问题描述】:
我正在尝试从 Google 表格中提取数据并显示在具有特定 ID 的 H3 标记中。这是我的Google Sheet 的链接。我只想从该表中提取价格并显示在 H3 标签中。我怎样才能做到这一点?
代码.gs
function doGet() {
var temp = HtmlService.createTemplateFromFile('index');
temp.list = getValues();
return temp.evaluate();
}
function getValues() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var ws = ss.getSheetByName('Sheet1');
var lastRow = ws.getLastRow();
var numRow = lastRow - 1;
return ws.getRange(2,1,numRow,2).getValues();
}
HTML
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<h1>50-74 gallons: </h1><h3 id="firstPrice"></h3>
<h1>74-99 gallons: </h1><h3 id="secondPrice"></h3>
<h1>100-124 gallons: </h1><h3 id="thirdPrice"></h3>
</body>
</html>
【问题讨论】:
标签: google-apps-script google-sheets google-sheets-api spreadsheet