Loop through excel files and upload each one individually in a website

Hello everyone. I have the following problem.

I have a number of excel files which is going to be different every time inside a folder on my computer. I need to create a loop and upload each single excel separately. One by one. How can I do this? Thank you!

@Veskata ,

We could first get the Excel Files in the Folder using the below Expression :

filePaths = Directory.GetFiles("YourFolderPath","*.xlsx").ToArray

Here, filePaths is a variable of type Array of String.

We could then loop through these file paths using a For Each Activity and perform the Operation of Upload inside it.

Hi @Veskata

  1. Use Assign activity
Arrstr | Variable Type -> Array(String)= Directory.GetFiles("YourFolderPath","*.xlsx")
  1. Use Read range activity → Store it as Dt

  2. Use For each row in Dt activity

image

Regards
Gokul

Thank you Roman Reigns I will try this and get back to you in a couple of minutes!

1 Like

@Veskata ,

Alternately, You could also use the For Each File in Folder Activity :
image

HI @Veskata

You can try like

  • For each file in folder

Regards
Sudharsan

Okay but how do I increment so it uploads the next file with each iteration?

@Veskata ,

Could you let us know what activity or method was used ? Or a Screenshot of your current Implementation ?

The For Each Activity iterates through each of the collection items, in your case the file paths one by one sequentially (Similar for the For Each file in Folder activity ). You would not need to provide an incrementer like with a While or a Do While Loop approach.

Let us know if you still have doubts about the activity execution or give a First Try and Check what is the outcome.

Okay so I need to click here


and then a folder with the excel files shows up. This needs to happen lets say 10 times. and each time the next file to be selected.

You dont need to increment it will automatically take the next file in the folder @Veskata

For each file will work same as For each row in datatable

For each row in datatable get each every row one by one
For each file in folder get each and every file one by one

Regards
Sudharsan

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.