Data Table Loop Through Columns and Rename each column

I have a data table with unnamed columns. How do I loop through each column and add a name to each column?

I tried using a for each loop to iterate through DataColumns but I get error Option Strict On disallows implicit conversions from System.Data.DataTable to System.Collections.IEnumerable

Try this -

columnCount = myDataTable.Columns.Count
For Each index in columnCount
{
     myDataTable.Columns(0).ColumnName = "newColumnName"
}
1 Like

Currently doing this in For Each activity, I get error Value of type Integer cannot be converted to System.Collections.IEnumerable

1 Like

renamecolumn.xaml (8.2 KB)

This shows you the way to do it. You can come up with different ways to provide the new column names but this simple example should help. The output of this example looks like:

image

A simple table of names and ages. I changed Column2 to “Names” using the workflow

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