How to get header name of columns and validating it

Hi, @ppr
I need to get all columns headers to be validated in excel please help

below is the expression I am using but error is in screen shot please check I have alredy set the for each to data column

col.ColumnName.equals(ColumnRefNames(idx)) And col.DataType = GetType(String)

@ks185332 Most probably I think that the type argument in the For Each should be changed to System.Data.DataColumn

yeah its already in DataColumn type

@ks185332 What is the value given to For Each? out_dtItemDetails.Columns ?

yes it is

@ks185332 Is there any other variable with the same name as that of “col” ?

no there is no variable created with the name of ‘col’

@ks185332 Can you replace the variable name “col” with “item” wherever the col has been used. Just to confirm there are no similar variables and that the problem arises from something else. :sweat_smile:

Hey now its gone after the Col to item but no results giving as matching or not matching,
Could you please help is there anything that I need to add/change

@ks185332 For that we might need to know what is the Data in the Datatable that you are using and what operation do you want to perform, and the output that you expect?

below are the column headers in the excel and I storing the excel data in out_dtitemdetails


and I have added Column headers into type string with var name as ColumnRefNames

and tryign to print them with the help of condition in for each loop
col.ColumnName.equals(ColumnRefNames(idx)) And col.DataType = GetType(String)
Please help how to compare/ validate the header names from excel

@ks185332 Ok. So the condition describes that you want to print only the Column names which are the same and are in order with the ColumnRefNames and have the same type. Is that right?

thats correct

@ks185332 What’s present in the else part of if condition?

forget about Else part now thats not mandatory

@ks185332 I mean depending on the condition the Control will move either to the Then Part or Else Part :sweat_smile: So if the Condition matches Whatever is present in then Part will be executed, if not matching whatever is present in else part will be executed.