将属性添加到Html模板会给出错误“对象不允许添加或更改属性” [英] Adding a property to an Html template gives error "Object does not allow properties to be added or changed"
问题描述
我尝试从我的Google Spreadsheet中检索数据,但是当我尝试将数据
对象添加到我的 htmlTemplate $ c $ b> object,我收到错误
'对象不允许添加或更改属性'
我的代码很简单:
function showDialog() {
var htmlTemplate = HtmlService.createHtmlOutputFromFile('index');
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var range = sheet.getDataRange();
var values = range.getValues(); //获取电子表格数据
htmlTemplate.data = values; //错误在这里
...
}
有谁能告诉我什么这是错误的吗?
而不是 createHtmlOutputFromFile(filename)使用 createTemplateFromFile(filename)
上面是因为第一个返回一个HtmlOutput对象,它不是允许添加属性,而第二个返回允许添加属性的HtmalTemplate。
I am trying to retrieve the data from my Google Spreadsheet, but when I try to add the data
object to my htmlTemplate
object, I receive the error
'Object does not allow properties to be added or changed'
My code is pretty simple:
function showDialog() {
var htmlTemplate = HtmlService.createHtmlOutputFromFile('index');
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var range = sheet.getDataRange();
var values = range.getValues(); //get the spreadsheet data
htmlTemplate.data = values; // error here
...
}
Could anyone tell me what is wrong with this?
Instead of createHtmlOutputFromFile(filename) use createTemplateFromFile(filename)
The above because the first returns a HtmlOutput object which not allow to add properties while the second returns a HtmalTemplate which allows to add properties.
这篇关于将属性添加到Html模板会给出错误“对象不允许添加或更改属性”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!