Pleas refer this post : Copy particular column rows from excel to another excel - #8 by lchirathapudi
This post was created to copy single column values to another excel and i got the solution. However my requirement has changed:
This works when we want to copy only one column values :
Excel.Sheet(“HCT_DialoguserList”).Range(“B25:B”+Excel.Sheet(“HCT_DialoguserList”).DataTableValue.Rows.Count.ToString)
Can you provide the activity to copy multiple columns values to another excel?
For example :
I want to copy User group,Valid from,Valid to & Reason for User Lock columns values to another excel
Hi @Sathish_Kumar_S
You can use the below workflow,
→ Use the Build datatable activity and give the columns which you want to store and store the datatable as Input_dt variable.
→ Use Excel Process scope activity inside of it insert the Use excel file activity and give the path of the Input file.
→ Inside Use excel file activity insert the Read Range activity to read the excel and store in a datatable called Input_dt. Give the Range as below in Range field,
Excel.Sheet("HCT_DialoguserList").Range("B27:V"+Excel.Sheet("HCT_DialoguserList").DataTableValue.Rows.Count.ToString)
→ Uncheck the Has headers option of the Read Range activity.
→ After Read Range insert the Assign activity and use the below LINQ Expression,
- Assign -> Output_dt = (From row In Input_dt
Let Usergroup = row(1).ToString()
Let Validfrom = row(7).ToString()
Let Validto = row(9).ToString()
Let ReasonforUserLock = row(18).ToString()
Select Output_dt.Rows.Add({Usergroup, Validfrom, Validto, ReasonforUserLock})
).CopyToDataTable()
→ Outside of Excel Process scope activity insert the write range workbook activity to write the Output_dt to the ExpectedOutputExcel.xlsx file.
Use the below workflow for better understanding,
DateTime_Practice.xaml (19.5 KB)
Check the below output file,
expectedoutput.xlsx (9.7 KB)
Hope it helps!!