Getting column heading from Excel row

I am trying to extract the top row of a worksheet as a list or array that can be iterated to perform operations.

I used this as a guide:

I used a “Read Range” activity and assigned the result to a generic list with LINQ
dtData.Columns.Cast(Of DataColumn)().[Select](Function(x) x.ColumnName).ToList()

this produces a valid list as viewed in the immediate window

I used the resulting list in a “for each” activity which compiles but freezes upon stepping
into. Any ideas to correct this?

I tried as .ToArray() but still freezes

@Phil_Kelsey

If you need to loop through each column then you can directly use dt.Columns in the for loop in argument property

CurrentItem.ColumnName will give the name of column

Hope this helps

Cheers

This ideally won’t happen

I believe you are running in normal mode and not in debug mode
Try restarting your machine and open studio and run the process

Let us know if u r facing any further challenges

Cheers @Phil_Kelsey

@Phil_Kelsey

Datatype Of ListVariable

I used Anil_G’s suggestion to just use dt.Column

to get the column number in the worksheet
aInt32=dtData.columns.IndexOf(“ColumnName”)
to get the column letter in the worksheet
aString = convert.ToChar(i+65)
adjust for zero based array as you see fit.

1 Like

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