ReadRange error....Please look further into fixing this problem

Continuing the discussion from System Workbook activity - Read Range: Syntax Error:

I encountered this same issue when trying to “ReadRange” (not excel).

Based on the error I got…

RemoteException wrapping System.Exception: Syntax error.
at UiPath.Excel.Activities.WorkbookActivity`1.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

If you break down the error… “UiPath.Excel.Activities.WorkbookActivity`1.EndExecute” method has an unhandled syntax error that occurred. If you ignore fixing this, then you seriously undermine the stability of the “ReadRange” activity. You should own the UiPath namespace.

To recreate this issue, you must cause the execution to fail while reading a workbook and then debug with the code behind of the “EndExecute” method available.

Hey @CSharpCoder
If you don’t mind can you please put the screenshot of your code? It will help us to more understand the problem.

Thanks,
Shreyash

Appreciate your assistance. Suffice it to say, the table range, file path, and sheet are valid (as you can see it successfully got the “tableRange” variable populated from the activity “Get Table Range” that was executed right before this).

Please ensure your are providing the range in correct format.

ex: “A1:C20”

If all parameters are good then upgrade the package and debug again.

image

Thank you.

Hi @CSharpCoder

In READ RANGE activity mention the range as “”
So that it will read from starting cell till end.

Table range is valid (as I said it was given from the activity that happened).
And the UiPath.Excel.Activities package is already version 2.11.4

Calling the same Sheet Name many times in the Read Range under same scope will be a problem. Not so sure about this. Can you please try changing the Sheetnames and confirm this?

Thank you.

Just because you populated that variable from an activity doesn’t mean the value it contains is correct for Read Range. Show us the actual value in that table range variable.

1 Like

It isn’t blank. The value of the variable is “A21:E28”. I changed the value to empty string and the same error happens. I changed the sheet name to one that doesn’t exist and the error changes to “The sheet does not exist”. And changed the document path to “” and of course it got another error “Workbook Path needs to be set”. I bring these up since it seems most of the underlying code is working. That doesn’t take away from needing additional troubleshooting.

I changed the sheet name (still pointing to the same XLSX, and it seemed to not error.

This problem never happened until I ran and got an error with Assistant. And now it happens when running from Studio as well. Also, I copied the XLSX and ran automation on it and same problem happened. I executed this on a XLSX file that hadn’t had a problem during the execution and no problem happened. Of course, the problem still happens on the same file or a copy of the same file.

I think the problem has to do with the XLSX file saving with an invalid sheet property when it fails for another workbook/sheet activity. This should be able to be resolved in a “Finally” block when an error occurs during processing. The “Finally” block should open the sheet and ‘save’ it. Hopefully that doesn’t mean it needs to open Excel and save, since that would cause an undue reliance on the “Excel” Application for the Workbook Read Range activity.

You could probably avoid all this by using the Workbook activities instead of Excel Application Scope. In general, for simple things like Read Range, the Workbook activities are more reliable.

Sorry for any confusion, but I am already using Workbook (which just happens to come from the UiPath.Excel.Activities namespace.) The full official namespace for Workbook Range Read is “UiPath.Excel.Activities.RangeRead”.

Turns out Write Range (workbook version) changes all functional values to text instead of preserving the formulas, so it isn’t particularly useful when that is needed.

I will be resorting to probably using Excel Application Scope instead since formula preservation is important to me.

That the activities are in the Excel package doesn’t mean anything. The way Workbook activities interact with Excel is different than Excel Application Scope. But yes, there are cases where EAS is unavoidable.

Appreciate your response.

Turns out WriteRange & ReadRange must not be used repeatedly too fast. They seem to work as long as they aren’t called back to back. Still think there’s a problem and no official solution to this problem. Seems no one is motivated to delve deeper into this problem.

1 Like