Append Excel Rows
Append Excel Rows
Section titled “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).
How it works
Section titled “How it works”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
DBNullleaves 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.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
data | DataTable | — | The DataTable whose rows will be added. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanExcelSession | — | Excel Open session (instead of path). |
path | string | — | Path to the .xlsx (created if it doesn’t exist; required if there is no session). |
sheet | string | int | — | Sheet name or index; created if it doesn’t exist. If omitted, the first sheet (or "Sheet1" in a new workbook). |
Output
Section titled “Output”This activity does not return a value.
Common errors
Section titled “Common errors”| Message | Cause 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. |
Example
Section titled “Example”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 = todayResultsThe first run creates the sheet with headers; each following day adds the new rows below, without duplicating the titles.
Related activities
Section titled “Related activities”- Append Excel Range — add values without a header.
- Write Excel Sheet — write a table from scratch.
- Read Excel Sheet — read the accumulated data back.