Hi All,
I have 2 excel files, test1 and test2. I am comparing test1.xls with test2.xls using first Column.
I need to write the unmatched data in second tab of test1.xls.
Read 2 excel files store the output into 2 dataTable variable.
Create third datatable variable with same structure as first datatable. you can do this by using clone method like below or you can create using build datatable activity.
3rdDataTableVariable = 1stDataTableVariable.Clone
Use 2 for each datarow loops with 1st datatable as input in outer loop and 2nd datatable in inner loop.
With if condition check first column 1st datatable matches with first column of 2nd datatable, if value matches in inner loop set boolean variable value to “True”(Scope of boolean variable must be body of the outer loop) if you required you can compare 2nd columns from both 1st and 2nd datatables also. After completion of inner loop before going to next iteration please check the value of boolean variable.
If boolean variable value is true don’t do anything, if value is false add that row from 1st datatable to 3rd datatable.
outside outer for loop write the 3rd datatable to required excel file.
DataTableVariable3 = (From x In DataTableVariable1 .AsEnumerable()
where (From y In DataTableVariable2 .AsEnumerable()
where convert.tostring(x(“Billing ID”)).equals(convert.tostring(x(“ID”)))).count=0
Select DataTableVariable1.Clone.Rows.Add(x.itemarray)).copytodatatable
@Manjuts90 and @parvati : I checked both the workflow and ran few scenarios. It seems to be working perfectly for me!!! Thanks a lot to both of you. Closing the thread. Sorry I am allowed to check only 1 checkbox as solution.