How to add three data tables into one data table

I have 3 Data tables DT1 with the “Item” column
DT2 with the “Property” column
DT3 with the “Info” column
I want to add/append all these columns into a single data table. Say FinalDT.
Need to use only 1 “Write Range” activity.Merge is not working.
Any suggestion is appreciated.

Screenshot (92) + Screenshot (91) + Screenshot (93)

The excel should be in the below form

side by side merge

  • done by combining the datatables within a datable (Classical, LINQ…)
  • repeated write range with offset A1,B1,C1 for the different datatables

We are doing it in this way as e.g. in contrast merge datatable will not do a side by side merge


Use 3 Write Range activities and pass DT1, DT2 and DT3 respectively to it.

Mention Range as “A1”, “B1” and “C1”.

@lakshman Thanks for the suggestion. Now I’m following the same process where 3 “Write Range” activities write into same excel. This reducing the performance(Opening and closing excel so many times).
That’s why i want to add columns into single data table and write into excel.

@ppr please look into this How to add three data tables into one data table - #5 by Kavya_Mamidishetti2

Using Merge the output is something like

@postwick Thanks for the response. Merge didn’t work.

Create an empty datatble with the three cols with the help of Build datatable - dtMerged

then use an assign activity:
left: dtMerged

(From x in Enumerable.Range(0, dt1.Rows.Count)
Let ra = new Object(){dt1.Rows(x)(0),dt2.Rows(x)(0),dt3.Rows(x)(0)}
Select dtMerged.Rows.Add(ra)).CopyToDataTAble

Feel free to use ColName instead of ColIndex

in case ofg the datatables will have different row counts we can adopt also have a look here:

1 Like

Why didn’t it work? It should. It’s what it’s for.

Hey @ppr Thanks a ton. That’s working amazingly. Thanks for quick response too.

yes, but it is writing data in the below format. However, solved the problem.

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