How to rename Column headers of datatable without adding headers in read range?


I need to change the names of few headers in an excel file. While reading the excel file with add headers enabled I get the following error " A column named ‘PNR’ already belongs to this datatable.

Hence I’m trying to rename the Headers with add Headers disabled.
I need to rename the following Headers:
1.PNR = "PNR " - cell reference A45
2.ACI IND = "ACI IND " - cell reference A82
3.POS CNTRY = "POS CNTRY " - cell reference A95.

I have attached the excel attachment for reference
Sample.xlsx (9.3 KB)

Any help or leads to solve the issue is much appreciated.

1 Like

Hey @Sirimalla_Karthik_Chandra

You can do this,


  1. dt_Data(0)(col_idx) = "PNR "

Similarly for next two

Alternate Approach,

For-each item with collection dt_data(0).ItemArray

   Switch item

       Case PNR 

             dt_data(0)(indexFromForeachOutput) = "PNR "

       Case ACI IND
             dt_data(0)(indexFromForeachOutput) = "ACI IND "

Hope this helps


1 Like

Thank you @Nithinkrishna. It is working

1 Like

Cool :slightly_smiling_face::+1: @Sirimalla_Karthik_Chandra

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