Skip to content

Append Excel Rows

Type: excel-append-rows  ·  Package: Excel Activities v1.0.6  ·  Output: —

Adds the rows of a DataTable at the end of the existing data on a sheet. Its key behavior: it writes the headers only if the sheet is empty. So the first time it creates the table with its titles, and after that it only adds rows below, without repeating the header. It is the ideal activity for accumulating data across runs (a history, a daily log, growing results).

It finds the last row with content on the sheet (looking at every column). If the sheet is empty, it writes the headers (the DataTable’s column names) in row 1 and the data below; if it already has content, it only adds the rows right after. It always starts at column A. Accepts session or path — see the two modes.

  • If the file or the sheet don’t exist, they are created (and that first write includes headers).
  • Columns are written by position, not by name: keep the same column order on every run.
  • Values are written with their type and DBNull leaves the cell empty — see how the data arrives.
  • In fast mode it saves the file when done; in session mode, on Excel Save or Excel Close.
ParameterTypeDefaultDescription
dataDataTable—The DataTable whose rows will be added.
ParameterTypeDefaultDescription
sessionZoanExcelSession—Excel Open session (instead of path).
pathstring—Path to the .xlsx (created if it doesn’t exist; required if there is no session).
sheetstring | int—Sheet name or index; created if it doesn’t exist. If omitted, the first sheet (or "Sheet1" in a new workbook).

This activity does not return a value.

MessageCause and fix
'data' is required.data is empty or the expression returned null.
'data' must be a DataTable.data is not a DataTable (for example, a DataRow or a list). For a single row use Append Excel Range.
'session' or 'path' is required.Neither session nor path is set.
The process cannot access the file '…' because it is being used by another process.The file is open in another program when saving. Close it or retry with Retry.

A daily process that keeps accumulating its results in the same file:

... build the "todayResults" DataTable ...
Append Excel Rows path = "C:/reports/accumulated.xlsx" sheet = "Results" data = todayResults

The first run creates the sheet with headers; each following day adds the new rows below, without duplicating the titles.