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.
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”
Step 3:
Drag “Output Data Table” activity into the design panel and convert Datatable to String type.
Step 4:
Drag “Message Box” activity into the design panel to display the modified data table.
Step 5:
Finally, let’s run the project.
Click here to download the Source Code…
Hope it has helped you…