For each excel in a folder

excel
loop

#1

I want to open all the excel files in a folder.
In order to achieve it, I created a variable of String[] and Assigned it to Directory.GetFiles(“C:\Users\folder path”,"*.xlsx" ). In For Each loop, I changed TypeArgument to String. Somehow, it is not working, though it worked perfectly fine for pdf file loop (for each pdf in a folder). Does the variable/ argument type need to be changed in this case? Please guide here.


#2

hey @igul

Please try this workflow and let me know and replace your folder path before to run it.

TogetExcelfiles.xaml (7.7 KB)

let me know your feedback.

Regards…!!


#3

Hi @aksh1yadav,

It correctly identified the excel file format in a folder with if, then write line debug.
However, I am still unable to open the excel file through “open application”. Its selector is wnd app=‘excel.exe’ cls=‘XLMAIN’ title=‘Name_*.xlsx - Excel’ />. The excel files have similar names such as name_1, name_2 and so on.


#4

hi @igual

why you wants to open an excel file by using excel application because you can perform all excel operation without manually opening it.
just use Excel scope activity and within that by using other excel supported activites like read range and all you can perform read and write data on an excel file as well.

Regards…!!


#5

Thanks. It worked.
I was trying to test something else through “open application.” However, “excel application scope” also acted as a workaround.


#6

Hey @igul

If you wants to a flexibility in workflow to read and write data in the excel file. Variable is to required to have flexibility in case the folder changes or the file name is slightly modified when the bot is run next time.

please find attached sample workflow and let me know :stuck_out_tongue:

Igul_RPA_Solution.xaml (16.7 KB)

Let me know in case of doubt or any clarification.

Happy Learning…Uipath…!!

Regards…!!


#7

It worked perfectly fine in case the folder name is updated. However, it runs on all the excels within the folder. For now, this solution helped in achieving my task.
I will open a new thread later for reading excel with similar names like excel_1, excel_2 etc.


#8

hi @igul

To achieve the above you said you can use condition like same name file creation date basis.
to get more info on this to check file creations date and all, see this thread.

Let me know if you wants more help on this.

Thanks& Regards…!!
Aksh


#9

Could you Upload your pdf loop referred to in you question above please. I haven’t even got that far.
Ty Ryan


#10

In a folder n number of excel files are there (30 to 50 excel files).
I have to delete the 1st column in every excel file and also append it into the single excel file.
Please some one share the solution for this .


#11

@aksh1yadav

Hi Akshay Yadav,
I want to read the data from excel files which is placed in a folder(the folder contains 30 excel files),
here i want to check the data in each excel file by using date or some id(if any of the excel file contains the data related to what i have searched is to be written into another excel file).