How To Compare Two Excel Files Of The Same Format And Get Matched Data?

While dealing with data table operations, sometimes we might want to compare two data tables and get matched data

(From a In SourceDT.AsEnumerable Join b In Destination_Table.AsEnumerable On a(“Column_Name”).ToString Equals b(“Column_Name”).tostring Select  a).CopyToDataTable.Select().CopyToDataTable().DefaultView.toTable(False,”Name”)

Replace “SourceDT” and “DestinationDT” with your required data tables and “Column_Name” with your required column name that you want to match with

Example

Implementation using UIPATH:

Let us implement a workflow which takes two excel files as input and gives us matched data between those excel files as output

Step1:

Drag Read Range(Here I have used workbook activity) activity and read “excel file1” and get datatable1

Drag Read Range(Here I have used workbook activity) activity and read “excel file2” and get datatable2

Step2:

Drag “Assign” activity into the designer panel and fill it with the above-mentioned code.

Step3:

Drag “MessageBox” activity to display the result.

(Note: Here I have used LINQ to display the DataTable instead of output Datatable)

Step4:

Finally, Execute the workflow !!!

Click Here to download the source code

Hope it has helped you……..

Advertisements

Leave a Reply