Compare headers and paste under the corresponding header of excel

Hi,
I have an excel with column header Name,Age in column 1 and 2 respectively. I have and other excel with the same headers but also extra headers. i want to read the excel 1 and paste the values under the corresponding headers of excel 2.Is there any other method of doing this like any linq query other than the normal read and write ranges.
image-excel1

image-excel2

we would still use read range / write range

before writing dt1 to dt2 we harmonize the columns e.g.

  • filter datatable, removing Country Column

OR

  • dt2 = dt1.DefaultView.ToTable(false, new String(){Name, Age})

OR

  • combinations e.g. with LINQ for more control and generative calculations on the structures
    e.g. fetch only dt2 columns from dt1…
1 Like

lets be more sharp on namings

vs

a range info

to short cut it (we ommit some elaborations on append range, dt2 to write = dt2 in Excel…)

One technique is to use the name manager / naming the entry cell and using it as a range info

we told you already options as you can also split dt2 and write the columns seperately