Linq to compare a column in Excel using a variable

Hi team,

I am having one scenario where I need to filter a Excel column using the one value.

Example, I a have a value let’s say the value is sreenivasa and I need to check in a excel column 0 for this value.

if this is present in Excel it should be true otherwise this should false.

Kindly help me on this scenario with Linq,

Thanks
Happy Automation

Hi @srinusoft37

Can you try this

isValuePresent = dtExcel.AsEnumerable().Any(Function(row) row.Field(Of String)("columnName").Equals("sreenivasa", StringComparison.OrdinalIgnoreCase))

Cheers!!

1 Like

Hi @srinusoft37

Try this:

Assign activity:
isValuePresent = dtExcelData.AsEnumerable().Any(Function(row) row.Field(Of String)(0) = "sreenivasa")

Regards

1 Like

Hi @srinusoft37

- Assign -> Bool_Var = dt_Input.AsEnumerable.Any(Function(X) X("Column 0").toString.Equals("sreenivasa"))

Note - Bool_Flag is the boolean datatype variable

Hope it help!!

1 Like

Thanks for Quick reply,

All 3 are working as expected.

3 Likes

It’s my pleasure… @srinusoft37

Happy Automation!!

HI @srinusoft37

Thank You

Happy Automation!!

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