Excel Online — Used range
Excel Online — Used range
Section titled “Excel Online — Used range”Type: excelonline-get-used-range · Package: Excel Online v1.0.4 · Output: Dictionary<string,object>
Returns the dimensions of a sheet’s used area: how many rows and columns hold data and the range address. Use it to know how much to read or where to start writing without assuming a fixed size.
How it works
Section titled “How it works”It works on the session created with Excel Online — Connect. Pass it in the session parameter, or place this activity inside the body of Excel Online — Connect to inherit it automatically.
The used area is the smallest rectangle that contains every cell with content or formatting. Therefore:
- It does not always start at
A1: if the data starts atB3, the address starts there. - Cells with formatting only (borders, color) make it bigger even if they are empty.
- On an empty sheet, Microsoft 365 reports
A1(1 row, 1 column).
It is read-only: it does not modify the workbook.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
sheet | string | — | Sheet name. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanExcelOnlineSession | — | Excel Online — Connect session. Inherited inside Connect’s body. |
Output
Section titled “Output”Returns a Dictionary<string,object> with three keys:
| Key | Type | Content |
|---|---|---|
rows | int | Number of rows in the used area. |
columns | int | Number of columns in the used area. |
address | string | A1 address of the used area, prefixed with the sheet name: Data!A1:D250 (in single quotes if the name has spaces: 'Sales 2026'!A1:D250). |
Access by key: used["rows"], used["address"]. To use the address in another activity on this sheet, drop the prefix: used["address"].ToString().Split('!')[1].
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
No Excel Online session available. Provide 'session' from an excelonline-connect activity, or place this activity inside the Connect activity's body so the session is inherited automatically. | The activity is outside Connect’s body and did not receive session. Place it inside the body or pass session = workbook. |
'sheet' is required. | sheet is empty or its expression returned null. |
itemNotFound (Microsoft Graph, 404) | There is no sheet with that name. |
Example
Section titled “Example”Excel Online — Connect credential = credential("m365-finance") path = "Reports/Data.xlsx" └─ body: Excel Online — Used range sheet = "Data" → output: used Excel Online — Read range sheet = "Data" range = used["address"].ToString().Split('!')[1] has-headers = true → output: table Log message = "Data rows: " + (Convert.ToInt32(used["rows"]) - 1)Related activities
Section titled “Related activities”- Excel Online — Read range — read the used range.
- Excel Online — Append rows — add at the end.
- Excel Online — Clear range — clear the range.
- All Excel Online activities