apps-script-utils 2.1.1 Help

getSheetByIndex

function getSheetByIndex( sheetIndex: number, spreadsheet?: GoogleAppsScript.Spreadsheet.Spreadsheet | undefined | null ): GoogleAppsScript.Spreadsheet.Sheet | null;

The index counts from zero, left to right as the tabs are shown. It is a position, not an identity: moving a tab changes what this returns, which is why getSheetById is the one to store.

An index past the end gives null rather than an exception.

Parameters

Parameter

Type

Description

sheetIndex

number

The zero-based position.

spreadsheet (optional)

GoogleAppsScript.Spreadsheet.Spreadsheet \| undefined \| null

The spreadsheet to look in. The active one by default.

Returns

GoogleAppsScript.Spreadsheet.Sheet | null — the sheet, or null when the index is past the end.

Examples

Looking up

const first = getSheetByIndex(0);

See also

Source

src/appsscript/sheet/getSheetByIndex.ts

23 September 2026

This documentation was generated with AI (Claude) from the library's source code.