How to initialize a DataColumn and insert values into it?

I am able to add values into a DataRow object(‘Add DataRow’ activity->Properties->ArrayRow)

But I am not able to achieve the same for a DataColumn, because I see no options in the properties pane of Add DataColumn activity.

Any ideas?

@Athrix05 use build data table activity refer This zip file

Hi @Athrix05

You can add values to a data column by looping through your data table and using an assign activity within a loop

Use a for each row activity to loop though the datatable
In the assign activity
Target is row("ColumnName")
And for the value property you can provide the value

Additionally, if you want to add a column for a existing data table to add values using above method, you can use add data column activity to create a column

1 Like

You can use add data column activity to add additional column on the predefined datatable.

@singhonkar @Lahiru.Fernando
Thanks for the reply, but I am looking for something else.

Please check this thread for a different angle to my question.

Eventhough the threat is not active any more, I think it worth mentioning the answer as it seems like many people are wondering and the question does make sense. I was quite baffled myself, so when I cannot find sufficient answers in the otherwise solid UiPath documentaion and community, I refer to the dotnet documentation, which proves to be useful for indept check of some objects.

DataColumn was never intent to be a value carrier object, it is a metadata object. From dotnet documentation:

"The DataColumn is the fundamental building block for creating the schema of a DataTable. You build the schema by adding one or more DataColumn objects to the DataColumnCollection. "

For me this is a bit of a bad architecture, as excel information seems to be logically grouped in columns, so a DataColumn object used just for defining schema feels like wasted opportunity, plus creates inconsistency with the dataRow object. I think it is a good opportunity for the UiPath team to build a DataColumn child object, which can be initilized with an array, values can be added and removed and can be passed to AddDataColumn or similar method to append the column with the values to a table. Just a personal oppinion.

1 Like