How to rename a column and change column position in a datatable | UiPath

Pradumn Kumar
2 min readAug 31, 2022

--

While dealing with datatables, we come across scenarios where we need to change the Column Name & Column Position before we use it in next steps.

Let’s see how we can achieve it in UiPath..

Example

Prerequisite ->

As we need a datatable for this demo, we will read a sample test file to get the content as datatable. Here’s a snap of our current datatable:

Solution ->

We will first change the name of Column2 by setting the “ColumnName” property of this column to NewName. Here’s how to do it in UiPath :

Now, we will use “SetOrdinal” method to make this NewName column as the first column in our datatable. We will pass in 0 as the input parameter for it to become the first column. Here’s how to do it in UiPath :

Fig: Input parameter property of the invoke method activity

Tip ->

  1. We can always use the column index instead of column name!
  2. Pass in 1 in the input parameter of invoke method to put the column in 2nd place!

Result ->

Lets have a look at the below changed datatable. We can observe that the column name of Column2 was changed to NewName and it is now in the 1st position!

Thank you for your time !! See you soon..

Feel free to show your appreciation by clicking on the Clap icon below & Follow me here for more such easy to understand content. I am also available on LinkedIn :-)

--

--

Pradumn Kumar
Pradumn Kumar

Written by Pradumn Kumar

Hey there! I’m a software professional with 5+ yrs of overall experience. I’ve deep interest in tech and geopolitics, which lures me deep into these topics.

Responses (1)