这可以使用Gsheet AppScript中的rangenames来处理吗?我遇到此错误:'typeError:sheet.getRangebyName不是函数。
我正在尝试在AppScript中的对象中添加一些静态范围名称,我这样做是为了具有更大的灵活性,因为有20多个变量(列),因此,如果您尝试在Google表中添加一列,则代码为没有损坏,这是我已经编码的简化示例:
var sheet = SpreadsheetApp.getActive().getSheetByName('Form Responses');
var bot_id = sheet.getRangeByName("bot_id");
var elements = {
bot_id: bot_id,
}
var res = elements.bot_id.getValues();
但是,当我运行它时,我会收到以下错误:“ TypeError:Sheet.GetRangeByName不是函数”。
我该如何修复它并始终引用同一张纸,还有另一种更轻松,更有效的方法吗?
I am trying to add some static range names to an object in AppScript, I do this to have more flexibility since there are more than 20 variables (columns) and so that if you try to add a column in the google sheet, the code is not damaged, this is a simplified example of what I already have coded:
var sheet = SpreadsheetApp.getActive().getSheetByName('Form Responses');
var bot_id = sheet.getRangeByName("bot_id");
var elements = {
bot_id: bot_id,
}
var res = elements.bot_id.getValues();
However, when I run it I get the following error: "TypeError: sheet.getRangeByName is not a function".
How can I fix it and always be referencing to the same sheet, is there another easier and more efficient way to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
getRangeByName()
不是表格的方法,而是电子表格。因此,您应该尝试:getRangeByName()
is not a method of Sheet but instead of Spreadsheet. So you should try:这样尝试:
Try it this way: