Merge same data in 2 difference data table excel to 1 data table excel

sorry, im really new with uipath. Can i know how to merge the same data in 2 excel to 1 excel only. tq
example, same data excel A + same data excel B = excel C

@syaheed22

You can read both excel’s and store the data in their respective data tables like dt1 and dt2. Use merge data table activity to merge the dt1 as source and dt2 as destination under property field.

Use write range activity to create excel with dt2.

1 Like
  1. Read Excel1 into DataTable1 (Read Range Activity)
  2. Read Excel2 into DataTable2 (Read Range Activity)
  3. Merge DataTable Activity to merge both DT1 and DT2
  4. Write Range Activity to write to a new Excel.
1 Like

but i only need the same data in dt1=dt2 to make dt3. Dont want all data merge

Hi @syaheed22,

Can you be more specific , what do you mean by same data.

Suppose first excel have 5 rows and second excel has 3 rows, do you want to combine in 3rd excel and want to have 8 rows, please specify your requirement clearly.

sorry,
its actually, i want only same primary key in dt1 and dt2…
example:
dt1:
1 abc
2 def
3 ghi

dt2:
1 abc
3 ghi
4 jkl

output i want:
1 abc
3 ghi

@syaheed22

You can use for each row activity for iterating through all rows.

Flow should be like :

  1. Create data table dt3 using build data table.
  2. For each row for dt1.
  3. For each row for dt2.
  4. If condition to compare the value of primary key.
  5. If both are same, then use add row activity to dt3.

At last, you’ll have only rows in dt3 with same primary key. Use write range activity to create output excel with dt3.

Let me know if you have any questions.

why it said the column name not exist?
is it correct condition?
dt2.Select("[aa no]=’"+row1.item(“aa no.”).tostring+"’")

@syaheed22

If the above condition is to compare the primary key for both dt’s , then it should be like

row2(“aa no”). ToString.equals(row1(“aa no.”). ToString)

option strict disallow implicit conversion string to integer. i have no idea rn

@syaheed22

If possible, can you please share screenshot of that part where this message appeared.

Hi Syaheed22,

Have attached the xaml file for your reference with the sample excel data as you mentioned. This will result the output in the sheet3. Please have look if it suffice the problem you stated.

PrimaryData.xaml (9.6 KB)

ExcelData.xlsx (9.6 KB)

1 Like

Hi Syaheed,

Please make sure if this packages are upto date.

image

Hi,
Sorry, i cant update it, my studio version lower than it. Do u have another way?

@syaheed22 ,

I’ve made use of linq expression to achieve the result. Please find the attached xaml file for your reference. Hope this helps
PrimaryData.xaml (9.8 KB)

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