Add Data Row/Column
The example below explains how to build a DataTable with columns and rows by using the Add Data Row, Add Data Column, and Output Data Table activities. You can find these activities in the UiPath.System.Activities package.
This is how the automation process can be built:
- Open Studio and create a new Process.
- Drag a Sequence container in the Workflow Designer.
-
Create the following variables:
Variable Name Variable Type Default Value DT1DataTable new DataTable ArrayOfValuesSystem.String[][] {({"A1","John","6"}),({"A2","Jamie","3"}),({"A3","Jim","9"}),({"A4","Janice","5"})}DataTableStringString TableHeadersSystem.String[] {"Id","Name","Grade"}
-
- Drag a For Each activity inside the Sequence container.
- Add the value
headerin the ForEach field. - In the Properties panel, select the String option from the TypeArgument drop-down list.
- Add the variable
TableHeadersin the Values field.
- Add the value
- Place an Add Data Column activity inside the For Each activity.
- In the Properties panel, add the value
headerin the ColumnName field. - Add the variable
DT1in the DataTable field. - Select the String option from the TypeArgument drop-down list.
- Select the check box for the AllowDBNull option.
- Add the value
100in the MaxLength field.
- In the Properties panel, add the value
- Drag a For Each activity below the previous For Each activity.
- Add the value
rowin the ForEach field. - In the Properties panel, select the System.String[] option from the TypeArgument drop-down list.
- Add the variable
ArrayOfValuesin the Values field.
- Add the value
- Place a Add Data Row activity inside the For Each activity.
- In the Properties panel, add the value
rowin the ArrayRow field. - Add the variable
DT1in the DataTable field.
- In the Properties panel, add the value
- Drag a Output Data Table activity below the last For Each activity.
- In the Properties panel, add the variable
DT1in the DataTable field. - Add the variable
DataTableStringin the Text field.
- In the Properties panel, add the variable
- Drag a Write Line activity underneath the Output Data Table activity.
- Add the variable
DataTableStringin the Text field.
- Add the variable
- Run the process. The robot creates the DataTable by adding columns and rows.
-
This is how your workflow should look:

-
Here you can download an example.