While loop excel

hello guys please help😭

so i have to automate a process where i have to take information from excel sheet and put it into a website form.

but here’s the problem, the form can only submit 4 companies at once meaning it can only extract the first 4 rows of information in excel, but i have more than 4 rows/companies that i need to submit

how can i automate the process in a way i can submit the next 4 rows after the first 4 rows until excel has an empty row?

i need to be able to submit the next 4 or less than equals to 4 companies after the first 4 companies. how do i create this process

thanks

@meenyi

Dt.AsEnumerable.chunks(4)

Use the above as input argument to for loop and till the items are completed the loop would run giving 4 or less items each time till the items complete

Cheers

@meenyi,

You will have to get this by reading the excel file into datatable and splitting it’s rows into chunks of 4. Here is sample solution.

For Each activity Argument Type = Int32``List of items

Enumerable.Range(0,Cint(Math.Ceiling(dt1.RowCount/intChunkSize))).ToArray

Get Chunk of DataTable:

Full Solution:

Sample Code:

Data.xlsx (11.3 KB)
Workflow.xaml (10.1 KB)

Output:
image

You can add your logic to enter these 4 rows into form as per your requirement in For Each loop.

Don’t forget to mark my answer as solution. :smiley:

Thanks,
Ashok :slight_smile:

hi where do i input this at?

hi! will this process allow me to submit the next 4 or less companies inside the form?

thanks

@meenyi

this si how it looks

currentitem.copytodatatable is the table contianing your required rows…for each iteration those would change

cheers

@meenyi

Yes! It will do that.

may i know what is the log message, output data table and log message inside the body for?

thanks

hi! it is not working😭 it doesn’t just submit the first 4

hi this doesn’t work😭 it does not only key in 4 entries

@meenyi,

Hey it’s just to print the 4 rows picked in the current iteration. It was for demo purpose only. You can remove it and add your logic to fill your form.

Thanks,
Ashok :slightly_smiling_face:

@meenyi

Then the flow you are doing inside this loop is wrong may be…the ask was for getting 4 rows each…inside that no detaila are given…

Can you please show what are you doing and what failed…that would help than not working

Cheers

hii my apologies, because it’s confidential information hence i’m unable to show u how is it like. but allow me to breakdown…

basically in a website for me to submit forms, i can only submit 4 companies at once as its a limit from the website.

however, the excel that i read these companies information from has more than 4 rows,

how do i make the process such that im able to submit the first 4 companies and still followed by the next 4 companies until they finish submitting all companies.

for example if i have in a total of 14 rows, how can it submit 4 at once then the next 4 then the next 4 then the remaining 2?

hope this is clearer

thanks

@meenyi

This explanation is understood and the idea given above is for splitting into those chunks only…when you say not working what is happening?

When you say submit 4 in chunks…how are you doing it? Did you first happen to check the loop and see if 4 items are coming pr not?Did you understand that first? Did you find a solution on how and what to write inside loop?

Cheers

hi i tried another method by using while loop
but it still doesn’t works😅, please help if possible

for example my excel has 6 rows in total but 1 row is the header so means there are 5 rows of information.

i’ve set the rowCount to Int32 default:0 and totalRows to Int32 default:6

however it is still capturing the 5 row items

thanks

@meenyi

Please use a for loop as mentioned above that would be straight…

Because ai believe…you are checking all conditions but in the for each row in datatable you are still passing full datatable so it is looping whole…that is where for loop with currentitem.CopyToDatatable will help

Cheers

hi are you referring to this?

does it mean i used for each instead of while?

and currentItem.copytodatatable do i need to change anything or this is it?

hi thanks! however it’s still reading the rest of the rows, not just the first 4 rows

thanks

@meenyi,

If you need only the second chunk. here is the updated solution.

Output:
image

Sample Code:
Workflow.xaml (11.4 KB)

Thanks,
Ashok :slight_smile:

@meenyi

yes that is what you need to use inside the if condition and the for loop datatable inside it

cheers