How to insert a column in existing excel in the first place?

excel

#1

Hi all,
I have an excel sheet with some columns in it. I want to add new col Sr. No. in the 1st place of the excel sheet. I tried with add column method, but that adds col at the end. Does anyone know how this can be done?


#2

Hi @Komal_Joshi,

  1. Read Excel using read range into DataTable.
  2. Use Invoke method-SetOrdinal method to change column position.
  3. Write the updated DataTable back to excel using write range.

Check this topic if it answers your query.

Regards,
Rahamat


#3

Hi Thanks a lot. :slight_smile:
Can I ask you one more doubt…
When I am creating a new column using Add data column activity, providing a column name specifically as “Sr. No.”, most of the time Column1 name is created and the data to be written in Sr.No. col is getting printed under Column1. Where as Sr. No. column is created in next index with no data and just with the name. No where I have mentioned Column1, it’s coming by default but I dont want it.
Can you please take a look at it? Please let me know if you can tell me the workaround on this.