Development doubts

Guys if anyone can help, I have to develop a robot that in the input are several folders inside each folder has an excel file, (or it can be a single folder with all these excel files inside) I have to read all these folders and the excel files inside each to put this data inside SAP, (or enter a single folder with all excel files inside) does anyone know how to do it? There are 8 Excel files.

you can get the files in the folder using,

Directory.getFiles(“FolderPath”)

you will be getting array of string, which contains all files in that directory…

You can loop it with for each and Check whether it is xlsx or xls i.e check whether it is excel… and process the excel file

1 Like

If you need all the folders inside the directory,

You can use
Directory.GetDirectories(“Directory Path”)

how would i do for example if i had 8 excel files inside the same folder? using reframework, would you use this Directory.getFiles (“FolderPath”) and how would you make a datatable of them inside init?

If all files are in the same folder, like Sweety_Girl mentioned, use Directory.GetFiles(“Your_File_Path”)
If all files are not in the same folder but are in sub-folders, use Directory.GetFiles(“Your_File_Path”,"*.xlsx", SearchOption.AllDirectories)

If you would like to build a data table of of these file directories instead of having it in an array of strings you could put it in a for each loop as so:

for each

And the properties for the Add Data Row would be as follows:

data row

Make sure you use a Build Data table activity before entering the for loop as well. Pass out the datatable from the init section of the REFramework and set this created data table as your transaction data.

Ok, thankyou.

Just to make this more clear:
Create a variable of type String Array varMyFiles
Assign it like this: varMyFiles = Directory.GetFiles("c:\myfolder","*.xlsx", SearchOption.AllDirectories)
Create a For Each of type argument String:
For Each file in varMyFiles
Use a Excel Scope activity and use file as the path to every excel file it finds.

1 Like