"For Each Excel Row" not working as intended

So I have an excel, which I read, and then want to perform some checks by using “For Each Excel Row” but using that gives this peculiar error:


You can also see in the immediate window, “CurrentRow” is not even coming, even though the excel is perfectly fine.

Please help me fix this. Thanks in advanced.

@Biswas_Ishan

It seems like you’re encountering an issue with the “For Each Excel Row” activity in UiPath, where the “CurrentRow” variable is not recognized. This could be due to various reasons, such as incorrect variable scope or data type mismatch

  1. restart studio once and check

@Biswas_Ishan

Take a log message before if condition Print

Currentrow("Comments").ToString

if it is printing Items then check the if condition

Or
Put the Reference excel i will help you to overcome the error

Hi @Biswas_Ishan ,

When The error is coming , when the bot is still in execution state, Navigate to the watch panel add two expressions,

Expression 1 : CurrentRow.ByField(“Comments”).Tostring
Expression 2 : CurrentRow.Item(“Comments”).Tostring

Please use the expression that returns the value in the watch panel, Expression 2 is what is being used inside the if condition, I highly doubt that there might be an issue in expression only. Do check and let me know if it works. Happy to assist further if required.

Happy Automating…!

Thanks,
Gautham.

Hi @Biswas_Ishan

Make sure your column name doesn’t contain any extra spaces and try printing it in Message Box before If condition the same condition. Try using .Trim() after .ToString().

Regards

This didnt work. I restarted, still problem persists.


As you can see, i put a logg message, and in the ouput panel, there is a blank line, and it will be blank, for this row, that is, the first row, as it is blank, but it might have some value.

What I mean to say, ‘Comments’ column might be filled or blank, i want to check if it equals “OAB Comp to be updated”, only then want to perform the subsequent checks.

PS: Also sorry, cant share the excel file, as it is confidential.

Here’s the watch panel as u wanted:

Ya I made sure, there isint any spaces in “Comments” column name

Hi @Biswas_Ishan

Can you share sample excel if it doesn’t have confidential data.

Regards

I am really sorry, but I cannot share the excel, as it contains confidential data.

Hi @Biswas_Ishan ,

Please try using the if’s condition as,

CurrentRow(“Comments”).ToString.Equals(‘Value to be checked as string’)

Happy Automating .!

Thanks,
Gautham.

while comparing it is best practice to convert it into lower or upper case.
Instead of giving direct value convert both to either upper or lower case check in immediate panel and proceed.

It is actually failing in if condition.

Hope this helps…

Did what you said, not working still:

Tried this, still giving the same error

@Biswas_Ishan

Please share the Sample excel and your process xaml

I am sorry the excel is quite confidential, and thus cant share it, sorry.

share the screenshot of the immediate value what are the values you are getting

Thanks everyone for taking their time and helping out. Thanks a lot. But I found the fix, I did this:


And now the program ran perfectly, so it is solved.
Thanks again everyone for helping out.
I am closing this thread.
Thank you
Regards

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