Excel File Issue

Hi Guys

I have a excel file which has 100 records. Script is ready to be executed. At a time it should read only 20 records and execute the script and then followed by next 20 and so on.

Issue : How to read only first 20(Row 1 to 20) and execute the script and followed by next (Say 21 to 40th row)

Thanks
Kamesh

@Kamesh

Use a condition like your values should be less than or equal to 20 .then it will goes to the loop else break the condition .

:slight_smile:

Take a Counter variable start from 1, Start increment it by 1 after every successful process when if reaches 20 break out of the for each loop

Thanks a lot thing is that excel can contain any count of orders say sometimes 100 sometimes only 50 or 500 like that

It will not matter. The loop will break at the count of 20

when the loop breaks at 20 then it will again start 21st row in excel ? Can you please explain it

Thanks Sob If the loop breaks at 20 i want to execute the script again starting 21st row from that excel

Hello @Kamesh
do like this
read all data from excel in table dt
then
if dt.rows.count > 20 then
tempdt = dt.select(“1=1”).Take(20).CopyDataTable
dt = dt.select(“1=1”).Skip(20).CopyDataTable
else
tempdt = dt
end if

your code here…

in above tempdt will have only 20 rows that you want to work with…

What @AkshaySandhu has suggested would also work and you can work with the counter as well. Don’t reset the counter and use rowIndex to get the value

Thanks a lot !!! will try

Thanks a lot !!! will try

1 Like

Can you please tell me how to use rowIndex activity in excel

Things i planned Create a counter with default as 0 If counter < 20 proceed the work once it exceeds break out of the if loop and then assign or reset the counter to 0 (how to start the row index from 21)

DataTable.Rows(RowIndex)(ColumnIndex).ToString

Thank you so much