> ## Documentation Index
> Fetch the complete documentation index at: https://explore.airia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# List Worksheets

> List all worksheets in a OneDrive-hosted Excel file.

The **Excel — List Worksheets** step returns the worksheets inside an Excel file with their IDs, names, positions, and visibility. Use it to discover what worksheets exist in a file before reading or writing — typically as the first step in a loop that processes every tab.

***

## Prerequisites

* The **OneDrive Excel** steps must be enabled on your workspace (feature flag: `step-sdk-onedrive-excel`).
* A **Microsoft OAuth credential** with at least read access to the file.
* The Excel file already exists at the configured **Path**.

***

## Inputs

| Parameter      | Required | Description                                                             |
| -------------- | -------- | ----------------------------------------------------------------------- |
| **Credential** | Yes      | The Microsoft OAuth credential used to access the file.                 |
| **Path**       | Yes      | The file path in OneDrive, for example `/Documents/MySpreadsheet.xlsx`. |

***

## Outputs

| Variable     | Type    | Description                                 |
| ------------ | ------- | ------------------------------------------- |
| `Worksheets` | `array` | One entry per worksheet, in workbook order. |
| `TotalCount` | `int`   | The total number of worksheets returned.    |

Each worksheet entry exposes:

| Field        | Description                                                             |
| ------------ | ----------------------------------------------------------------------- |
| `Id`         | The Graph-assigned worksheet identifier.                                |
| `Name`       | The worksheet name (the tab label in Excel).                            |
| `Position`   | The zero-based index of the worksheet within the workbook.              |
| `Visibility` | The worksheet's visibility state: `Visible`, `Hidden`, or `VeryHidden`. |

Reference the list as `{{Steps.List_Worksheets.Worksheets}}`.

***

## Examples

### 1) Process every visible worksheet

1. **List Worksheets** — produces an array of all worksheets.
2. **Filter step** — keep only entries where `Visibility == "Visible"`.
3. **Loop step** — iterate over the filtered list and for each item:
   * **Read File** with `Worksheet Name` set to `{{Steps.Loop.CurrentItem.Name}}`
   * …and downstream processing.

### 2) Check whether a worksheet exists before writing

1. **List Worksheets**.
2. **Compare step** — does `{{Steps.List_Worksheets.Worksheets}}` contain an entry with `Name == "Today"`?
   * If yes → **Write Row** to `Today`.
   * If no → [Add Worksheet](/building-and-deploying-agents/agent-basics/onedrive-excel-add-worksheet) named `Today`, then **Write Row**.

***

## Notes and limitations

* Returns worksheets in workbook order. Reorder downstream if you need a different sort.
* Hidden worksheets are included — filter by `Visibility` if you only want visible tabs.
* The step does not return cell data. Use [Read File](/building-and-deploying-agents/agent-basics/onedrive-excel-read-file) for values.
