I have an Excel file and a data table that I need to add to it. However, the table’s columns don’t directly match those in the Excel file, so they need to be reordered. For example, column H of the data table needs to be placed in column D of the Excel file, and so on for other columns.
How can I do this?
Anil_G
(Anil Gorthi)
October 22, 2025, 10:06am
2
@alexis.mendoza.rpa
you can use the following expression with column names in order you need
use assign with
dt = dt.DefaultView.ToTable(false,{"Col1","Col2"})
{"Col1","Col2"} - here you can specify the column names you need and in the order you need so that the columns are re arranged in datatable
cheers
Can I write more than 2 columns?
1 Like
Anil_G
(Anil Gorthi)
October 22, 2025, 10:10am
4
@alexis.mendoza.rpa
yes you can write any number..just for example I have written 2
cheers
1 Like
hi, @alexis.mendoza.rpa
Use Assign or Invoke Code to reorder columns by their index:
dt.Columns("ColumnH").SetOrdinal(3)
This Moves ColumnH to Excel’s column D position (index 3)
Repeat for other columns as needed.
Use Write Range activity to write the reordered DataTable to Excel.
edit- Also you refer to this
system
(system)
Closed
October 25, 2025, 10:11am
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.