ADD SERAIL NUMBER (S/N) INTO A DATATABLE

Hi ,
so i have an excel without a serial number
and i have done some process using DATATABLE

MY question is i want to create a new column (SERIAL NUMBER , S/N) on first column , and i want to do it directly using the original datatable,
any Suggestion guys?

ORIGINAL EXCEL
image

EXPECTED RESULT
image

Hi @Ahmad_Rais

Here is the workflow

Sequence1.xaml (9.0 KB)

Regards
Gokul

Hi @Ahmad_Rais ,

For a Datatable Manipulation, take a Look at the below post using the SetOrdinal Method :

An Alternate would be to use the Add Data Column Activity and then use Filter Datatable to arrange the Columns in the Proper order, this would require you to have the prior knowledge of the all the column names.

or using the DefaultView.ToTable method and using the Column names required to be present in the datatable in the order that is required like below :

DT.DefaultView.ToTable(false,"ColumnName1","ColumnName2",...)

For Updating the newly added Column we could use a For Each Row Activity after the Column Addition and then update the Serial Number Column.

We could also approach a Linq Update.

Let us know if you are facing any difficulties in the above methods.

Hi do you have to download other dependecies for that activities?
i cannnot seems to find the activities

HI @Ahmad_Rais

You dont need to install new dependencies for this ,You need to just enable modern design to get these activities
image

Regards
Gokul

seemslike im using studioX , is there any diffrence , caused i still unable to find it

Hi @Ahmad_Rais

As you need the S/No to auto incremented right based on row values we can try with the below xaml

Insert_Column_Infront(Autosaved).xaml (6.7 KB)

Regards

HI @Ahmad_Rais

Okay Do you have Excel Activities in your dependencies because i can find these activities in StudioX as well.

Regards
Gokul

Seems like for some reason it got turned off i will check it again

i can use it now ,
thanks for the new info

hay pravin thank for reply
but i can seems to see the workflow

Hi @Ahmad_Rais

For that part you can refer the screen shot below!

Regards

hi pravin isee that you assign the new column on index 0 , wont it just rename the column and not adding new column?
image

thanks

Hi @Ahmad_Rais

Sorry i had mistaken with wrong method!

Please refer to the SS below set ordinal method will be good approach!

image

Regards

Hi @Ahmad_Rais

Any clarification please let me know!

Regards

Hi i havetried you suggestion , it works for adding the column , but it needs to interact with the excel first and not the existing datatable

thank you

It will create the column in the excel not in the Datatable

yes , it works , but not really as i wanted , because i want to directly interact with an existing datatable, but its good to know the activity u just shared , thank you

i will try pravin suggestion next

Iā€™m bit confused about your query which you shared on both the replies

Anyway Try @pravin_calvin Suggestion too and let us know what you got.

Regards
Gokul

it works like a charm!!

can you please elaborate more
on the invoke method process?

thankk you

Sorry my english is a bit messy ,

Thank you for your help , its works !! ,
but just not as i want for this workflow

thank youu Gokul

1 Like