I have two excel file’s having sheet1(data) and excel sheet2(value) (both excel sheet row’s are not equal).
copy the first value (Ex: 234567) of column “number1” in excel sheet 1(data) and check with column “number5” in excel sheet 2(value) are matched or not. If not matched,paste into not matched excel file.
If it matched, again check the first value (234567) with column “number7” in excel sheet 2(value) are matched or not. If matched, paste into matched exce file
Again copy the second value (Ex: 234567) of column “number1” in excel sheet 1(data) and do the same.
Use the below linq code to get the desired result.
Get Records of DT1 which exists in DT2 - inputDT1.AsEnumerable().Where(Function(row) inputDT2.AsEnumerable().Select(function(r) r("ColumnName").ToString).Any(Function(x) x = row("ColumnName").ToString)).CopyToDataTable
Get Records of DT1 which does not exists in DT2 - inputDT1.AsEnumerable().Where(function(row) Not inputDT2.AsEnumerable().Select(function(r) r("ColumnName").ToString).Any(function(x) x = row("ColumnName").ToString)).CopyToDataTable()
How to use This linq with the help of IF condition.
If matched data are stored in exce file in then part and not matched data are stored in excel file in else part
To use in Linq in a if condition you need to check the count.
Instead of using .copytodatatable use .tolist() method and check the count of list.
If the count is greater than 0 then you have a dataset then do StrList.Copytodatatable in an assign.