I have two excel what i want to do is i want to check the slip number from excel 1 and check if that i available in excel2 if not available then save them in different DT excel1.xlsx (8.5 KB) excel2.xlsx (8.4 KB)
excel1 has multiple column with column name but required is slipnumber
excel2 do not have column name but its fixed row 0
Eg:
1.read 1st excel
2.read second excel(without add headers)
3. use this linq
(From DT1 In dt1.AsEnumerable() Join DT2 In dt2.AsEnumerable() On
DT1(“slipnumber”).ToString() Equals DT2(0).ToString() Select
DT2).ToArray().CopyToDatatable
in an assign activity.
note:dt1 and dt2 is two read range output.
In addition to above also have a look on the different Join Types
In your scenarion you will detect such records by
Join Type: Left Join
dtLeft: dt1, dtRight: dt2
Join Col - the slip number columns
Filter / Detection - dt2 from Join Pair is null
Tge corresponding LINQ would look like this:
dtResult =
(From d1 In dtData1.AsEnumerable
Group Join d2 In dtData2.AsEnumerable
On d1("slipnumber") Equals d2(0) Into gj = Group
From g In gj.DefaultIfEmpty
Where isNothing(g)
Select r = d1).CopyToDataTable
(
From item in dt_Excel1.AsEnumerable.Select(Function(r) r("slipnumber")).ToArray.Except(dt_Excel2.AsEnumerable.Select(Function(r) r(0)).ToArray)
select dt_Output.Rows.Add(item)
).CopyToDataTable
(From d1 In dt1.AsEnumerable
Group Join d2 In dt2.AsEnumerable
On d1("slipnumber") Equals d2(0) Into gj = Group
From g In gj.DefaultIfEmpty
Where isNothing(g)
Select r = d1).ToList