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
EXPECTED RESULT
Hi @Ahmad_Rais ,
For a Datatable Manipulation, take a Look at the below post using the SetOrdinal
Method :
How to change the ordinal or position of the DataColumn to the specified ordinal or position? Is it possible to reorder Columns? If yes, please share a sample script.
Issue/Query: How to change the ordinal or position of the DataColumn to the specified ordinal or position?
Resolution steps:
The above scenario is achievable with the help of Set Ordinal method.
Sample Excel/ DataTable Data: Consider the below data
[image]
Launch UiPath Studio and create a sample process.
Ensure to have ā¦
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
Gokul001
(Gokul Balaji)
February 17, 2022, 4:37am
5
HI @Ahmad_Rais
You dont need to install new dependencies for this ,You need to just enable modern design to get these activities
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
Gokul001
(Gokul Balaji)
February 17, 2022, 4:46am
8
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?
thanks
Hi @Ahmad_Rais
Sorry i had mistaken with wrong method!
Please refer to the SS below set ordinal method will be good approach!
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
Gokul001
(Gokul Balaji)
February 17, 2022, 6:18am
16
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
Gokul001
(Gokul Balaji)
February 17, 2022, 6:53am
18
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