How to change the datatable column sequence

I read excel by using read excel and stored data in datatable, now i want to change the datatable column sequence. Please give solution.

1 Like

Hi @AmolS,

I believe that in your case you could iterate between those columns and reorder their sequence by using an index array and a for each loop like the example below:

1 Like

Hey @AmolS

please find this attached sample solution(For demo)customized it as per your need if required and let me know :slight_smile:

Sample Solution.zip (5.9 KB)

Regards…!!
Aksh

5 Likes

Thanks Akshay…!

1 Like

I edited your code to write the modified data table in the excel sheet. The values are being modified in the same order as in the output panel. But how can I change the column names as well?

Hi @bristighosal910

You can use a simple Assign activity with the following code:
yourDataTable.Columns(0).ColumnName = "New Column Name"
or
yourDataTable.Columns("oldColumnName").ColumnName = "New Column Name"

2 Likes

You can use a simple Assign activity with the following code:

yourDataTable.Columns(0).ColumnName = "New Column Name"

or

yourDataTable.Columns("oldColumnName").ColumnName = "New Column Name"

Okay, thank you.

Thank you.