How To Rename DataTable Columns – In UiPath

In RPA as we work mostly with the excel application, there are so many operations that we usually perform on it.

What if we are asked to rename a column of a DataTable?

Let us see how to do it!!!

dataTable.Columns(“old_ColumnName”).ColumnName = “new_ColumnName”

Note:
1. old_ColumnName is the specific column that you want to rename
2. new_ColumnName is the column name with which you want to rename the above old column name with.

Example

Implementation using UiPath :

Let us implement a workflow which takes a sample DataTable as input and we will try to rename an existing column of it from “Name” to “FirstName”

Step 1:
Drag “Build Data Table” activity into the design panel and populate it with some sample data.

UiPath Rename DataTable Column Name 1UiPath Rename DataTable Column Name 2

Step 2:
Drag “Assign” activity into the design panel and fill it with above-mentioned code.

Note:
We are renaming “Name” column of above build DataTable to “FirstName”

UiPath Rename DataTable Column Name 3

Step 3:
Drag “Output Data Table” activity into the design panel and convert Datatable to String type.

UiPath Rename DataTable Column Name 4UiPath Rename DataTable Column Name 6

Step 4:
Drag “Message Box” activity into the design panel to display the modified data table.

UiPath Rename DataTable Column Name 5

Step 5:
Finally, let’s run the project.

UiPath Rename DataTable Column Name 7.PNG

Click here to download the Source Code…

Hope it has helped you… 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: