admin管理员组文章数量:1419583
It is my first time to develop the google script for my google sheet
Here is the code of my script
function doGet(e) {
var url = ''
var name = '無標題表單 (回應)'
var SpreadSheet = SpreadsheetApp.openByUrl(url);
var values = sheet.getSheetValues(1, 1, 1, 1);
Logger.log(values);
}
It is my first time to develop the google script for my google sheet
Here is the code of my script
function doGet(e) {
var url = 'https://docs.google./spreadsheets/d/1p3fW0Vkx89tdiws3Z-a5_LpLwyGYj7pacIek3f9Z96w/edit#gid=1862590156'
var name = '無標題表單 (回應)'
var SpreadSheet = SpreadsheetApp.openByUrl(url);
var values = sheet.getSheetValues(1, 1, 1, 1);
Logger.log(values);
}
When I run the script,and then it show the message "ReferenceError: "sheet" is not defined. (第 7 行,檔案名稱:巨集)"
I try to use the method in this article ReferenceError: "Sheets" is not defined but still cannot work. Thank you!
Share Improve this question asked May 14, 2018 at 9:00 void_serventvoid_servent 11 gold badge1 silver badge1 bronze badge 1-
5
add line
var sheet = SpreadSheet.getSheetByName('Sheet1')
. Define it first, then use. – Max Makhrov Commented May 14, 2018 at 9:03
1 Answer
Reset to default 2tl;dr
Change var SpreadSheet
to var sheet
in the provided code.
As the error message is explaining: The variable sheet
is not defined in the provided code.
This means at the point where sheet
is trying to be used, it does not exist yet. It will have to be defined first.
Try running one of the following before you use the variable sheet
var sheet = SpreadSheet.getSheetByName('YourSheetName');
or using .openByUrl
var sheet = SpreadsheetApp.openByUrl(url);
本文标签: javascriptReferenceError quotsheetquot is not definedStack Overflow
版权声明:本文标题:javascript - ReferenceError: "sheet" is not defined - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745317099a2653204.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论