Whats the difference between these two methods from class SpreadSheetApp in Google Apps Script?
Both return "currently active spreadsheet, or null if there is none". Whats the difference between them, exactly? When should I use each one?
Whats the difference between these two methods from class SpreadSheetApp in Google Apps Script?
Both return "currently active spreadsheet, or null if there is none". Whats the difference between them, exactly? When should I use each one?
For me they're quite interchangeable really. Both return Spreadsheet object and has access to methods available to Class Spreadsheet. Feel free to use whichever you prefer.
Same results:
Logger.log("getActiveSpreadSheet() "+SpreadsheetApp.getActiveSpreadsheet().getUrl());
Logger.log("getActive() "+ SpreadsheetApp.getActive().getUrl() );
They don't seem to return a pointer to the same animal. I don't know why (don't have time to investigate) but
getActiveSheet()
has the getRangeByName()
method - and the one from getActive()
doesn't have itgetActiveSheet()
doesn't have the getCharts()
method - and the one from getActive()
does have itEither something really over my head makes this justifiable or it is just dismal language/syntax design (maybe some legacy crap that never got resolved?)
getActiveSheet()
has getCharts()
, but doesn't have getRangeByName()
. The object is actually of a class Sheet, not Spreadsheet (as returned by getActive()
or getActiveSpreadsheet()
). Besides, the question in OP wasn't about getActiveSheet()
anyway. –
Upend Following this article, function getActiveSpreadsheet()
is deprecated.
So it's better to use function getActive()
.
© 2022 - 2024 — McMap. All rights reserved.
SpreadsheetApp.getActive() === SpreadsheetApp.getActiveSpreadsheet()
, and the answer wasfalse
, any ideas? – Prevalent