Created
August 21, 2023 19:08
-
-
Save emmaly/8e0e4e52f635ffc60962b0f16b883499 to your computer and use it in GitHub Desktop.
getSheetById.gs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @OnlyCurrentDoc | |
*/ | |
/** | |
* @param {SpreadsheetApp.Spreadsheet} spreadsheet | |
* @param {number} sheetId | |
* @returns SpreadsheetApp.Sheet | |
*/ | |
function getSheetById( | |
sheetId=-1, | |
spreadsheet=SpreadsheetApp.getActiveSpreadsheet() | |
) { | |
return spreadsheet | |
.getSheets() | |
.filter((sheet) => sheet.getSheetId() === sheetId) | |
.shift(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment