【发布时间】:2016-06-13 10:01:15
【问题描述】:
如果可能的话,我希望让“openById”自动找到它所附加到的电子表格的 ID?
目前,我正在将电子表格中的单元格提取到 HTML 模板中,该模板使用单元格数据填充设计。
如果用户“复制”电子表格,则 ID(我手动输入)仍然是我正在使用的原始电子表格的 ID,而不是他们正在使用的电子表格的新电子表格 ID。
是否可以动态获取脚本附加的电子表格的 ID?
// code.gs
function doGet() {
var template = HtmlService.createTemplateFromFile('index.html')
template.sheet = SpreadsheetApp.openById('THE SPREADSHEET ID');
// returning .evaluate() (an HtmlOutput object) will allow you to display this in a web app.
// to get the string HTML content, use .getContent() on the HtmlOutput
return template
.evaluate();
}
【问题讨论】:
标签: google-apps-script google-sheets