Skip to content

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.

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 at B3, 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.

ParameterTypeDefaultDescription
sheetstring—Sheet name.
ParameterTypeDefaultDescription
sessionZoanExcelOnlineSession—Excel Online — Connect session. Inherited inside Connect’s body.

Returns a Dictionary<string,object> with three keys:

KeyTypeContent
rowsintNumber of rows in the used area.
columnsintNumber of columns in the used area.
addressstringA1 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].

MessageCause 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.
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)