Read from excel without using the loop

How to process each item in an excel sheet ?

NB : Without using any kind of loop like" for each row " :neutral_face:


for processing each and every item in a sheet, it’s definitely required to iterate over each item atleast once.

Couldn’t understand your requirement for not looping. Could you please elaborate?

1 Like

When you say without using loop, are you trying to read just a single row from an excel file with multiple rows?

1 Like

It was asked during an interview… :grimacing:

Here we go. Just use “macros” and call it from UiPath .
please refer this.

1 Like

Also it depends on what you mean by “processing items”. If I want to write the sum of the first two columns into column C I can just Read Range and the add a new column to the datatable with the default value being the formula that add the corresponding relative cells. So I think it depends on the use case.


:dizzy_face: #triggered

(Disregarding for a moment what is the actual “processing” that needs to be done)

Sorry for the slight offtopic and I might be missing the point, but if I’d be in your position I’d inquiry the interviewer about why you’d need to do it. Fancy solutions might look impressive during interviews, but using the simplest method (loop) that fulfills business criteria (process all rows) is what gets projects finished.
To quote Joel Spolsky:

They are the kind of people who decide to refactor your core algorithms to use the Visitor Pattern, which they just read about the night before, and completely misunderstood, and instead of simple loops adding up items in an array you’ve got an AdderVistior class (yes, it’s spelled wrong) and a VisitationArrangingOfficer singleton and none of your code works any more.

Maybe I’m “broken”, but if there isn’t a good (or at least decent) answer to why you’d want to do something in a way that’s more complicated and it’s just for complexity’s sake, even if it’s “just an interview”, I’d probably answer “there is no reason to NOT do it with a loop then” and if they insist try to think of something on the spot or just say “Thank you” and try to finish the interview, because I already know that I don’t want to work there (this obviously depends on a lot of circumstances and varies case by case for each person).

Interview works both ways - they get to know you, but also you get to know them - who they’re looking for and what are they asking tells A LOT about what kind of team you will end up in. If the interviewer isn’t a part of the team, and it’s not a “phone 1st step interview” then it’s a yellow flag also - people not related to the team should not decide who is hired to it. It’s too easy to mishire someone if you won’t be working with them, that’s just asking for trouble…


Back on topic:
To add another option - recursive invokes used as a forward iteration method could work too.
But either way most solutions will just mask a loop (or a functional equivalent of a loop) while being vastly more convoluted. Loops are so prevalent in “transaction” processing (and in programming generally) for a very good reason.

Sorry for the rant… these kind of interview questions just really trigger me :confused: I’d really hope there’s a good reason why they disallow one of the most elegant solutions that it could be done with.


@andrzej.kniola Have you been to interviews recently :grin::joy:?

1 Like

The solution for this could be using an Orchestrator Queue to process items without iterating through a loop. any data in the excel sheet can be directly uploaded to the queue or using Read range into a Datatable and Bulk add queue items activity.