Build DataTable
Build DataTable
Section titled “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.
How it works
Section titled “How it works”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
nullvalue 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
datais already aDataTable(because the expression returns one), it is passed through as is. - List items that are not row objects are ignored; if
datais not a list, the result is an empty table with no columns.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
data | List | — | 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. |
Optional parameters
Section titled “Optional parameters”None.
Output
Section titled “Output”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.
Common errors
Section titled “Common errors”| Message | Cause 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. |
Example
Section titled “Example”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 = summaryRelated activities
Section titled “Related activities”- Add Data Row — add rows to the created table.
- Clear DataTable — remove the rows and keep the structure.
- Add Column — add a calculated column to an existing table.
- Read Excel Sheet — get a DataTable from a file.