Skip to content

Get Excel Sheet Names

Type: excel-get-sheet-names  ·  Package: Excel Activities v1.0.6  ·  Output: List

Returns a list with the names of every sheet in the file. Useful when you don’t know the sheet names in advance, or when you want to process every sheet of a workbook by looping through them.

It returns the sheet names in tab order, hidden sheets included. Accepts session or path — see the two modes.

Read-only: in fast mode it does not modify the file.

None — but you must set session or path (or be inside the body of an Excel Open).

ParameterTypeDefaultDescription
sessionZoanExcelSession—Excel Open session (instead of path).
pathstring—Path to the .xlsx (required if there is no session). The file must exist.

Returns a List of text values (string) with the sheet names, e.g. ["January", "February", "Summary"]. On a session for a new file where nothing has been written yet, it returns an empty list.

MessageCause and fix
'session' or 'path' is required.Neither session nor path is set.
File not found.path does not exist. Validate first with File Exists.
Extension 'xls' is not supported. Supported extensions are '.xlsx', '.xlsm', '.xltx' and '.xltm'.The file is not .xlsx/.xlsm. Convert it first.

Process every sheet of a workbook (with a session, the file is opened only once):

Excel Open path = asset("yearly.xlsx") → output: workbook
Get Excel Sheet Names session = workbook → output: sheets
For Each items = sheets itemVariable = sheet
└─ activities:
Read Excel Sheet session = workbook sheet = sheet → output: data
Log message = "Sheet " + sheet + ": " + rowCount(data) + " rows"
Excel Close session = workbook save = false