Skip to content

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

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.

ParameterTypeDefaultDescription
tableDataTable—The DataTable to clear, e.g. buffer.

None.

This activity does not return a value; it modifies the table in place.

MessageCause and fix
'table' must be a DataTable.table does not evaluate to a DataTable (empty variable or another type).

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 = buffer