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”
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.
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”
Drag “Build Data Table” activity into the design panel and populate it with some sample data.
Drag “Assign” activity into the design panel and fill it with above-mentioned code.
We are renaming “Name” column of above build DataTable to “FirstName”
Drag “Output Data Table” activity into the design panel and convert Datatable to String type.
Drag “Message Box” activity into the design panel to display the modified data table.
Finally, let’s run the project.
Click here to download the Source Code…
Hope it has helped you…