Skip to content

Excel Online — Append rows

Type: excelonline-append-rows  ·  Package: Excel Online v1.0.4

Adds rows right after the last data in a sheet, without overwriting what is already there. It is ideal for accumulating records (a log, the results of a process…) run after run, without working out where the sheet ends.

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.

In values you pass a DataTable (or a DataRow for a single row). The activity:

  1. Asks Microsoft 365 for the sheet’s used range and takes its last row.
  2. Writes the rows right below, always starting at column A, values only (without the column-name row).

The change is saved automatically. Keep in mind:

  • Cells that only have formatting (borders, color) count as used: if there are empty formatted rows at the end, the new rows land below them.
  • On a completely empty sheet, Microsoft 365 reports A1 as the used range, so the first appended row lands in row 2. Usually row 1 holds the headers.
  • With a table that has no rows it writes nothing and does not fail.
  • Each call recomputes the last row, so it is not idempotent: if you retry after a failure that did manage to write, the rows end up duplicated. If several robots append to the same sheet at the same time, they can overwrite each other; in that case, use one sheet per robot.
ParameterTypeDefaultDescription
sheetstring—Sheet name.
valuesDataTable | DataRow—The DataTable to append (or a DataRow for a single row).
ParameterTypeDefaultDescription
sessionZoanExcelOnlineSession—Excel Online — Connect session. Inherited inside Connect’s body.

This activity does not return a value. The change is saved automatically; the run log states how many rows were appended and in which range.

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. / 'values' is required.The parameter is empty or its expression returned null.
'values' must be a DataTable (or a single DataRow).You passed another type (a list or an array). Build the table with Build DataTable.
itemNotFound (Microsoft Graph, 404)There is no sheet with that name.

Log the result of each processed invoice:

Build DataTable
columns = arr("Date", "Invoice", "Result")
rows = arr(arr(DateTime.Now.ToString("yyyy-MM-dd HH:mm"), invoiceNumber, "OK"))
→ output: record
Excel Online — Connect credential = credential("m365-finance") path = "Reports/Log.xlsx"
└─ body:
Excel Online — Append rows sheet = "Log" values = record