UiPath.Excel.Activities.WriteCell throws an error when writing to an Excel file downloaded from the web

Hi Experts

I have created a module that is downloading a data export in .xls (97-2003 format) from a webpage. The file is loaded into a data table and updated. This part is working fine.

However I need to write back to the downloaded file. I am using the UiPath.Excel.Activities.WriteCell activity that does not require an Excel Application Scope. But apparently only one cell is written and then this error is thrown:

Message: Unexpected record type (DimensionsRecord)
Exception Type: System.InvalidOperationException

From what it seems it might be caused by the fact that the file is downloaded from the web. The standard in Excel (running O365) is to show a security warning whenever opening a file from the web.

In the Trust Center under Protected View I have disabled all settings. Additionally I have added the file path to Trusted Locations.

But still only the first cell is written. I have then opened the Excel file and added a blank space in one of the cells in order to be able to save the file. And then it is possible to run the code without any errors.

For some reason it seems that the “Protected View” is still in function blocking for UiPath to update the file. What I do not understand is why it can write one cell and not the rest (?)

If using an Excel Application Scope it runs without any problems even though the file has not been modified with a blank space after the download. But this is not an option since Excel will not be installed on the machine running the robot.

Any ideas?

Hi @jacchr

However I need to write back to the downloaded file. I am using the UiPath.Excel.Activities.WriteCell activity that does not require an Excel Application Scope. But apparently only one cell is written and then this error is thrown:

You need to use Write Range activity rather than Write Cell because Write Range writes the data table into excel while the use of write cell is totally different which you want.

Hope it helps!!

Best!!
Anmol

Hi @anmolk171

It is not the data table I need to write back to the Excel file. Basically I need to read a date from the data table, add a year to the date and then write the new date back to Excel in another cell. Hence I am using the WriteCell activity.

Hi @jacchr - Can you share the workflow if possible.

Hi @anmolk171

The attached file is just a randomly created file showing the context of the actual file. So what I need to do is to update every second line with the date + 1 year above.

Demofile.xls (20.5 KB)

Hey @jacchr - I am able to use write cell activity successfully. I think it is excel issue.

Hi @anmolk171

I can also write to the demo file I uploaded. I looked into the meta data of the exported file and can see that the workbook has been generated by a open source component called MyXls.

If I open the file and save it within an Excel Application Scope I am able to use the WriteCell activity without any problems.

So I guess it might be a compatibility issue with the file itself.

1 Like

You can close this thread.

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