How to add a Column Header to an existing Datatable

I have a data table with 5 data rows already present in it which has 10 columns. But column headings are not there for this data table. I have all the 10 column names in an array[string] variable. How to add those column names as a header to that datatable.
Your valuables insights will definitely help.
Thanks!

You set the column name by Assigning a value to yourDT.Columns(columnIndex).ColumnName

For example…

Assign yourDT.Columns(0).ColumnName = “Test”

This will make the name of the first column Test.

1 Like

Hi @Harsha_Vemula ,

You could try configuring the workflow as shown below :

ColumnNamesArray is a variable of the Type Array of String, DT is the datatable variable.

Also notice, the index i is created in the For Each activity.
As I have C# set as the Language, I did use Square Bracket to access each column by Index, but we can use the below if it is for VB :

DT.Columns(i).ColumnName
1 Like


But I am getting the error while assigning new column name. Not sure why. Please help.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.