Clear DataTable
Clear DataTable
Section titled “Clear DataTable”Type: clear-datatable · Package: DataTable Activities v1.0.5 · Output: none
Empties a DataTable: removes all its rows but keeps its columns (the schema).
How it works
Section titled “How it works”Removes every row from the table. Columns, their names and types are kept, so you can reuse the table with Add Data Row. Clearing a table that already has no rows is not an error: nothing changes. The run log states how many rows were removed.
DataRow objects you stored earlier in variables no longer belong to the table; don’t reuse them after clearing it.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
table | DataTable | — | The DataTable to clear, e.g. buffer. |
Optional parameters
Section titled “Optional parameters”None.
Output
Section titled “Output”This activity does not return a value; it modifies the table in place.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'table' must be a DataTable. | table does not evaluate to a DataTable (empty variable or another type). |
Example
Section titled “Example”Reuse a table as a buffer inside a loop:
Clear DataTable table = buffer
For Each items = batch itemVariable = item └─ activities: Add Data Row table = buffer values: { id: item.Id, total: item.Total }
Write Excel Sheet path = "C:/out/batch.xlsx" data = bufferRelated activities
Section titled “Related activities”- Add Data Row — fill the table again.
- Remove Data Row — remove a single row.
- Build DataTable — create a table from scratch.