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);
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745317099a4622269.html
评论列表(0条)