Insert column at first position


#1

Hi all

I am trying to search for the code that can help me insert column at a specific position ( namely 1st ) . Now i already have an excel sheet which is not in Table format - its just a plain excel sheet . I need to insert a "U Id " column at the A position , how can i do that ?? kindly help, thanks in advance !


#2

Hi @shaileshpathak,

Use Write Cell activity to insert the data into the Column.

Regards,
Arivu


#3

@shaileshpathak, Two ways,

  1. Datatable Column Re-Ordering
  1. Excel - Insert Column

Regards,
Dom :slight_smile:


#4

HI @arivu96 - I want to insert a new Column as UiD as the first column of excel, the Write Cell activity will overwrite the already existing Column Name rather than inserting a new column


#5

Hi @Dominic - this one would insert column to an empty sheet , what if i have two columns already existing - For example my first column is EventName, second one Date . So I need to add a column before EventName - as UiD .


#6

@shaileshpathak
You can do like this also

Add DataColumn Activity and give name UID

Then use like this
dt=dt.DefaultView.ToTable(False,“UID”,EventName",“Date”)
Now UID will become first column.

Regards,
Mahesh


#7

@shaileshpathak,

NO. It does even if there is/are column(s) in it. Because we have Position property just to make it more clear where 0 indicates the Very first column and so on…

The only limitation (as far as I know) - We need a readymade TableName for your sheet :slight_smile:

Regards,
Dom :slight_smile:


#9

@MAHESH1 - nice idea ! it works :smiley:
Thanks !


#10

@shaileshpathak

You can try this,
dt.Columns.Add(“UID”).SetOrdinal(0)

Regards,
Mahesh