Skip to content

Build DataTable

Type: build-datatable  ·  Package: DataTable Activities v1.0.5  ·  Output: DataTable

Creates a DataTable from scratch from its rows. Use it when you need to build a table yourself — to accumulate results, prepare data to write to Excel, or set up a structure you will add rows to — instead of reading it from a source.

In the Designer, data is edited with a table editor: you define the columns and type in the rows. Each row is a { column: value } object and each cell accepts a literal value or an expression. You can also pass an expression that returns a list of row objects (for example, a list of dictionaries).

  • Columns: come from the row keys, in the order they first appear. If a row lacks a key that other rows have, that cell is left empty.
  • Column type: inferred from the first non-null value in the column: text → string, integer → int/long, decimal → double/decimal, boolean → bool, date → DateTime. If every value is null or of another type, the column accepts any value (object).
  • Empty cells: a null value or an empty string is stored as a cell with no value (DBNull).
  • Incompatible values: if a non-empty value cannot be converted to its column type (for example, text in a column inferred as numeric), the activity fails naming the row and column; it never stores a wrong value silently.
  • If data is already a DataTable (because the expression returns one), it is passed through as is.
  • List items that are not row objects are ignored; if data is not a list, the result is an empty table with no columns.
ParameterTypeDefaultDescription
dataList—Table rows. Each row is a { column: value } object; cells accept literals or expressions. Also accepts an expression that returns a list of dictionaries or a DataTable.

None.

Returns a DataTable with one column per distinct row key and one row per row object, in the same order. Since columns come from rows, an empty data gives a table with no columns and no rows.

MessageCause and fix
The value in row …, column '…' is not compatible with the column type '…'.A value does not fit the type inferred from the first non-null value of that column (rows are counted from 1). Use the same type for the whole column: for example, all numbers or all text.

Create an invoice table with two rows and write it to Excel:

Build DataTable
data:
{ Customer: "Northwind Trading", Total: 1500000 }
{ Customer: "Southern Supplies", Total: 820000 }
→ output: summary
Log message = "Rows created: " + rowCount(summary)
Write Excel Sheet path = "C:/out/summary.xlsx" data = summary