Compare header Names of 2 datatable

Hi team,

Can anyone tell me how i can compare headernames of 2 datatable.
Both of them contains 54 headers.
If there is a mismatch in headernames then BOT will throw Business exception

Hi Zara,

Try this

dt1.Columns(0).ToString=dt2.Columns(0).ToString

Hope it will work

tried…but its picking only first header name…i want to match all 54 with the another 54

then You have to use nested loop for this. Let me show

1 Like

if u have any reusable code for this…pls share

@Zara
with following statement you will get the column names as list:
YourDataTableVar.Columns.Cast(Of DataColumn).Select(Function (x) x.ColumnName).toList

with the data set operations you can identify if its matching or not e.g. with intersect or except

Hi Zara,

Quick solution.

Cheers Sequence.xaml (10.4 KB)

1 Like

@Zara
find starter help here, using the set operation approach
Check_2DT_hasSameColNames.xaml (11.8 KB)

1 Like

CompareHeadersOfTwoExcels.zip (13.4 KB)
Hi,
Please find the attached workflow file.
Hope It can help. Mark as solution if it works

1 Like