I have one folder having 7 xslx file with all different name.e.g (A ,B ,C,D,E,F,G)
i have another file in which i having 7 sheets with same name e .g(A,B,C.D,E,F,G)
I want to copy data from file “A” and want to paste in sheet name “A” and same for all rest of files.
i think this can be done in assign activity by linq query…can any one tell me this linq query?
use assign activity
use for each for the arr_files
inside use read range for reading the each excel file
below that use write range activity for writing the back to excel
in the sheetname pass the values as Path.getfilenamewithoutExtension(currentItem)
you cannot write this by using linq query
Linq query is basically to iterate and do modifications in a datatable or any structured data
But this looks more like data preparation in excel file so let’s do with simple excel based activities
Hope the below steps would help you resolve this
- For this use a assign activity like this
arr_of_files = Directory.GetFiles(“your folderpath”)
Where arr_of_files is a variable of type array of string
- Now use a For each loop for this step where pass the above array variable as input and change the type argument as string
Inside the for each loop use READ RANGE WORKBOOK ACTIVITY and pass filepath as item.ToString and get the output as datatable named dt
Inside the same loop as a next activity use WRITE RANGE WORKBOOK ACTIVITY and pass input as dt and enable add headers and mention sheetname as Path.GetFileNameWithoutExtention(item.ToString)
This loop will do the stuff you want
Hope this helps
we can extend the statement to
taken from: [HowTo] - First Start with LINQ (VB.Net)
and are not bound to datatable or structured data. As long there is a LINQ provider (to Object, to XML, given by Newtonsoft for JSON…) available for us we can use LINQ
So a crosscheck with this rule in mind we do see, that the typical UiPath Excel related Activities are not offered within a LINQ ready usage.
So we recommend to go essential or within a hybrid approach
but its showing flowing error.
cannot be converted to “data table”.the selected value is incompatible with property type
use dt1 As it is a datatable datatype and remove toString
You are about to write a datatable variable named dt to an excel file
Write range activity accepts datatable as input
So we don’t need it to be converted from datatable to string with .tostring
Have only dt instead of dt.ToString
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.