Can I take one column from a datatable to another datatable?

I have 2 datatable:

  • datatable1:
    image

  • datatable 2 : newDatatable

The thing is: the client wants the robot to change the order of the columns putting: name, company, adress and telf.

I was thinking doing this assigning the columns in a new datatable using

assign
dt2 = dt1.columns(“name”)

but i dont know how to do this. Can you help me?

@KevinDS
give a try on

Assign Activity:
left side: dtReordered
right side: dtOriginVar.DefaultView.toTable(“False”, {“name”,“company”,“adress”,“telf”})

otherwise we can change the datacolumn position with the SetOrdinal method from the DataColumn

3 Likes

Hi Kevin,

There are two ways to change column sequence:

  1. Use setOrdinal method to change sequence of column.
  2. To get specific column use : DT_Table.DefaultView.ToTable(False,“ColumnName”) and you can write range this column to new excel file.

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