Weird problem with datatable and excel


I’m trying to copy a whole column from an excel file to another, using datatable tools. The thing is that the first time this doesn’t work (Write cell activity gives me an exception : IndexOutOfRangeException), but the second time i launch the workflow, it works !

I even tried to count the columns using Datatable.Columns.count. The first time I do that (When I launch the workflow for the first time), it gives me 13 (This is way I have the exception after! ), and the second time, 14. I really tried to figure out what is the problem, and what happens in the workflow that makes it work the second time, but I didn’t succeed.

You will find attached an exemple of the workflow I use, with two excel files. I’m trying to copy column “N” from one.xls to two.xls. This is just a dummy example that works from the first time (Since I can’t upload the original one because of my company’s restrictions). So do you see any clue about what happens or do you have any idea why this happens ?

Any help will be much appreciated. (16.2 KB)

1 Like

Does anyone have an idea about why this is happening ?

Did you try using workbook activity instead of excel one or the opposite?
When you copy some column with formula inside with a workbook activity it seems to have some strange behavior that not happening using the excel scope, maybe it’s your case here

While Read range make Add header property is true and

Instead Of Using column index number use column name.

Still have the same problem

I’m using Excel activities only

I have two ideas based on my similar experiences. This might not help you but I’m sharing anyway.

When you don’t specify/ set “” to Range in your Read Range activity, UiPath may read cells till the last cell in the Excel file.

You can find the last cell by pressing ctrl + end.
Is the cell on where you think it’s the last cell? If not it might cause unexpected result, so please set Range concisely or google how to change the last cell.

Note that if your Robot writes cells, the last cell might change after running Robot.
Thus your flow might change behavior in second running and returned different value as the number of rows.

UiPath sometimes throws IndexOutOfRangeException to me even the flow sometimes works fine.

What I did is to add delay activity before the activities related to the variable which caused the error, and now it always works fine!

I thought it’s because UiPath might start next step without waiting for previous step finishing all the processes, in a certain condition, I guess.


Unfortunately, I didn’t work.

I have the idea to make a first dummy robot, that will just open the first file and close it, and a second robot, that will do the whole job. My question now, is how can I do that, how can I make my first robot call the second robot ?

Thank you?

EDIT : I have an idea, do you think that there may be a problem with the excel file/signature generated by Excel Application when editing a file that was generated using Excel Scope Application Activity ?

I resolved the problem. There was a problem with the algorithm prior to the zip file I’ve attached.

Thank you all for your answers.

1 Like