google apps script - Set variable as sheet name -


i want variable "sheetname" name of active sheet. how do this? tried

    var sheetname = spreadsheetapp.getactivespreadsheet().getsheetbyname(); 

but did not work. anyone?

you're looking sheet.getname(), check documentation here.

var sheetname = spreadsheetapp.getactivesheet().getname(); 

the .getname() method exists in both spreadsheet , sheet classes. spreadsheet.getname() return name of document, while sheet.getname() give name of sheet within spreadsheet (the same name appears on "tab"). in google apps script, javascript, need pay attention return types of method or function calls make sure you're invoking right method in chain.

in example, .getactivespreadsheet() returns spreadsheet instance. in re-write, use .getactivesheet() instead, yielding sheet.


Comments

Popular posts from this blog

javascript - JS causing window size to be bigger than necessary - Dropdown bug -

How to mention the localhost in android -

php - Calling a template part from a post -