How to find excel column matcha with certain column names in list

Query to find that datatable column names should matches with the column name in the list
Please mention query here

nitialize a Boolean variable to store the result
Assign activity:
isMatched = dt.Columns.Cast(Of DataColumn)().Select(Function(column) column.ColumnName).SequenceEqual(columnNamesList)

Hi @Demo_User ,

An Alternate :

DT.Columns.Cast(Of DataColumn).All(Function(x)columnNamesList.contains(x.ColumnName))

columnNamesList is a variable of type Array/List of String where it contains all the column names to check, DT is the datatable variable whose columns need to be compared.

The above method doesn’t take into consideration the order of the column names as provided by @raja.arslankhan . But it does check if all the column names in the list is present in the datatable.

1 Like

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