I am looking to have 'openById' find the ID of the spreadsheet it is attached to automatically, if this is possible?
Currently I am pulling cells from a spreadsheet into an HTML template which populates the design with the cell data.
If a user 'makes a copy' of the spreadsheet, the ID (which I have entered manually) is still that of the original spreadsheet I am using, not the new spreadsheet ID of the one they are using.
Would it be possible to get the ID of the spreadsheet that the script is attached with dynamically?
// 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();
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…