Hi All,
I am trying to build workflow where I want to read one excel sheet and write data to destination sheet. But I want to write data into destination excel using column mapping.
Like column are similar in both excel but their sequence is not similar.
Can anyone advise?
Gokul001
(Gokul Balaji)
October 13, 2023, 4:52am
2
Hi @sayali_gujarathi1
Can you share the sample input and expected output?
Read the 1st excel file → dt1
Use Wirte range activity path of 2nd excel file → pass the dt1
Regards
Gokul
Thiswill not work here.
because whatever column position in my source excel , it is not same with the columns position in destination excel. but columns are same. So , i need to write data in destination sheet using column mapping.
Gokul001
(Gokul Balaji)
October 13, 2023, 5:55am
4
HI @`
In this case you can try with lookup activity to get the Rnage of the Column Header
@sayali_gujarathi1
Try this :
dt.AsEnumerable.Select(Function(row) dtDestination.Rows.Add(row("SourceColumn1").ToString, row("SourceColumn2").ToString, row("SourceColumn3").ToString)).CopyToDataTable
cheers…!
Hi @sayali_gujarathi1
Use Merge DataTable Activity :
1.Excel Application Scope
Read Range (dT1)
Read Range (dT2)
Merge Dt
Destination : dt1
Source : dt2
Missing Schema Action : (Add/Ignore/Error/AddWithKey) - select Add from this 4 options
Add : Add values below the actual values
Write Range (in New sheet Result) destination dt1
Code :
Input :
Output :
Hope it helps
@sai_gupta it is not working.
@Gokul001 Can you send me workflow image, if you have.
@sayali_gujarathi1
try this:
(From row In sourceDataTable.AsEnumerable()
Let newRow = destinationDataTable.Rows.Add(row("Column1"), row("Column2"), row("Column3"))
Select newRow).CopyToDataTable()
cheers...!
Once try with above steps and let me know @sayali_gujarathi1
Anil_G
(Anil Gorthi)
October 14, 2023, 5:04am
11
@sayali_gujarathi1
One way is to find the order of column in the destination…if this is already know then use filter datatable with givign the column names as needed
One more way would be to use setordinal and set the column position for eqch column and then write the data to destination
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 …
Cheers