How can I rename multiple excel columns to a same name?

For example
I want to rename all the columns (Employee1, Employee2,…) to Employee.

Hi @Sami_Rajput

Check out the thread

Regards
Gokul

Hello @Sami_Rajput

Just try as below. But I believe it will throw the error as data table will not accept columns with the same name.

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

Thanks

@Rahul_Unnikrishnan
Yes exactly, I have tried but got the exception
Is there a way to deal with this

Can you explain the actual requirement with the use case?

If the number of columns is static then maybe you can keep a static excel with the Header alone and then use Append Range activity to write to that excel.

Thanks

Make the first row of data in the datatable your column names. Then when you write to Excel, uncheck the use headers property.

@Rahul_Unnikrishnan
Actually, I then need to upload that excel file to Server and for that, I have to rename the columns

Ok…Then i think you can keep an excel template with Employee as a header for all the Columns. Then Append Range to that excel and then upload.

Thanks