How do we rename a column in excel?

I used read range to read an excel file and use for each to get the columns . for example I have the ff columns below and I wanted to rename the column “Rep” as you can see on the image below to "Representative " , how do we do it in UIPath?

dddd

@RajivKumar12

Hi again, For this you use a assign activity and give as below

DataTable.Columns(0).ColumnName = “ColumnNameyouwant”

for your reference

Follow Link

Hope this helps you

Thanks

1 Like

can i use a for each in DataTable.Columns(0) ?

@RajivKumar12

For Each you can use DataTable.Columns -> this will give you list

but DataTable.Columns(0)-> is a single value

So you can’t use For Each

Hope this clears you

Thanks

But I need the list Sir , cause I need to check each item in the list

But only the list of the first row columns and not include the values for example

@RajivKumar12

Can you tell your requirement clearly?

If you need list then you can use Datatable.Columns in For each and you can iterate between column names

Thanks

My goal is only to loop on the column headers nothing else

so if Ioop through this the output should be OrderDate , Region , Rep , Item, Units , Unit Cost , Total and should ignore the rest

dddd

@RajivKumar12

If the order of the columns are fixed then you can use

ForEach -> Datatable.Columns, In properties Index create a Variable for Index

Inside ForEach place a IF Condition and check Variable of Index <> 6

If it true then place your logic else place Break activity

Hope this helps you

Thanks

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.