Rearrange columns in an Excel spreadsheet

Hi, how do I rearrange columns in an existing Excel spreadsheet?


You may use Sort table or data table activity.


It can be done. Check the following post on rearranging datatable columns…

Let know whether it works

1 Like

Hi, I want to rearrange the columns in a custom order instead of sorting by rules, how do I do this?


You want rearrange the column positions right. For Example : if there three columns 1.Name,2.Address and 3.Number you want change like 1.Address,2.Number,3.Name.

if the above mentioned is your case then you can use setOrdinal method in invoke and do that.

and there is custom activity available for this which you can use below mentioned is the link.


Hi @Shiva_Karthik

Thanks, how do I rearrange the columns using custom code?


You don’t need to use custom code instead you can custom activity,and provide the required inputs as shown in the below screen shot.

To install this activity go to package manager in all packages search for set ordinal activity yo will get it.

Another wise you can use invoke method and use setOrdinal method in that and provide the input parameters in parameters field in properties either of the ways should work.

In the target object give datatable.column(index of column you want to move and in parameters give the newindex)


1 Like

try this:

  1. Read Range
  2. datatable.DefaultView.ToTable(False,arrayOfTargetColumnNames)
  3. Write Range