Excel.ReadFromFile operation failed

I tried using Excel.ReadFromFile node but it failed. I’ve read some topics on this forum but haven’t found any solutions.
I’m running Revit 2018.1, Dynamo 1.3.1.1736, windows 7 x64, Office 2010.
I’ve tried xls, xlsx files at many locations, all granted Editing permission to Every One (I guess I don’t need this because I’m only reading the file’s content) but all failed.

image

I’m coming to Dynamo as a python developer. I also read Dynamo source code on github that I assume to be the Node’s code. I also looked up in MSDN but couldn’t find any ReadExcelFile method of the WorkBook object. Is there something missing here?
Please help and correct me if I’m wrong.
Thanks!

1 Like

Which version of excel do you have on the system?

Can you post the xlsx file for someone to test?

@htlcnn, sometimes something goes wrong with Excel. Have a look at the known issues here:

Excel nodes can be rendered non-functional by bad registry data. To correct this: Go to Start–> Run → regedit. Browse to HKEY_CLASSES_ROOT–>TypeLib–>{00020813-0000-0000-C000-000000000046}. Delete the 1.8 key.

We recommend using Excel 2013 or higher. Excel 2010 works in most cases, but 2007 does not.

You can also dive into this thread, maybe, it’ll help you: Excel Nodes Fail Dynamo 1.1.0

3 Likes

Thanks @zhukoven, I deleted the 1.8 key in registry and restarted my PC. The node is working now.
Btw, I’ve taken some more time to read the source code of Dynamo and realized they overload the Excel class to have the ReadExcelFile method.

1 Like

Overloading is well over my head, but please post that to the github if you feel it would improve things by doing it differently. The dev team is much more active there.

I’m not a .NET developer and I’m also new to Dynamo, so I would choose to stick with python and make use of working nodes :slight_smile: .

1 Like

Hi! I am also having this problem after Windows did some updates on my computer (WritetoExcel and ReadtoExcel had worked beforehand). I followed the above instructions to access the registry - mine shows a 1.7 key and a 1.9 key. Does anyone know which would be the one to delete since my registry does not show a 1.8 key?

registry

I’ve had issues with the excel node as well. I have started to use a python code script which is more stable to read my Excel files.

import clr

clr.AddReference('Microsoft.Office.Interop.Excel, Version=11.0.0.0, Culture=neutral, 
PublicKeyToken=71e9bce111e9429c')
from Microsoft.Office.Interop import Excel
from System.Runtime.InteropServices import Marshal

path = IN[0]

# Instantiate the Excel Application
ex = Excel.ApplicationClass()
# Make it Visiable for us all to see
ex.Visible = False
# Disable Alerts - Errors Ignore them, they're probably not important
ex.DisplayAlerts = False
# Workbook 
workbook = ex.Workbooks.Open(path)
# WorkSheet
ws = workbook.Worksheets[1]
# Cell range
x1range = ws.Range["A1", "A4"]
x2range = ws.Range["B1", "B4"]

r1 = x1range.Value2
r2 = x2range.Value2

OUT = r1, r2

ex.ActiveWorkbook.Close(False)
Marshal.ReleaseComObject(ws)
Marshal.ReleaseComObject(workbook)
Marshal.ReleaseComObject(ex)
1 Like

Thanks @Danny_Bentley - this python code isn’t solving my problem either… it seems to be about the same code as the “Write Excel” node in Archi-Lab Bumblebee, which is not working for me either. I do notice that both your code and the Bumblebee code share the line

clr.AddReference('Microsoft.Office.Interop.Excel, Version=11.0.0.0, Culture=neutral, 
 PublicKeyToken=71e9bce111e9429c').

The registry on my computer shows two keys, 1.7 and 1.9.

1.7 displays:
Microsoft.Office.Interop.Excel, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c

1.9 displays:
Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C

Modifying the line of your code I referenced above to reflect either of the values for Version did not resolve the issue.

I am also noticing that the 1.7 key has a String Value that the 1.9 key does not; it is called “PrimaryInteropAssemblyCodeBase” with a value of
file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.Office.Interop.Excel/14.0.0.0__71e9bce111e9429c/Microsoft.Office.Interop.Excel.dll

I’m assuming this .dll is the reference your code is importing… In any case, it seems I need to delete one or both of the registries…? So frustrating that this issue just began after accepting an automatic Windows update!

Hi @awilliams

Could you let us know the below versions your currently using.

  • Windows
  • Revit
  • Dynamo
  • Excel

Hi @Kulkul - sorry, I should have thought to include before. I’m currently using the following:

Windows 10 Pro
Revit 2016
Dynamo 1.3.1.1736
Excel 2016

@awilliams Install this application https://www.auslogics.com/en/software/registry-cleaner/

It will automatically remove duplicate keys and keep the ones needed. Its a free tool.

Thanks @Kulkul - I used the tool and restarted my computer, reopened Revit & Dynamo, and the Excel nodes still fail… I suppose I’ll have to resort to reading/writing with CSV from now on :persevere:

What’s in the registry now relative to excel? You may want to reinstall dynamo, and attempt to read and write excel nodes without any custom nodes installed as another “troubleshoot the system” effort.

@jacob.small this is what is in the registry now:

I tried troubleshooting by reinstalling Dynamo without custom nodes/packages and the Excel nodes still aren’t working. Could you or someone share what their registry has in it so I can compare?

My IT department has me locked out of that, but I can ask around. Consider posting the issue to the Github page to get some more direct developer attention.

1 Like

@awilliams,

i only have the 1.9 key as well and i dont have those issues.

What you could try is backup your register and delete the 1.9 key?
If you can delete the 1.8 key then it shouldnt be a problem for the 1.9 key either, but always make a back up.

1 Like

@awilliams Why not just uninstall excel and re-install it.

2 Likes

Finally solved the Excel nodes working by uninstalling & reinstalling Microsoft Office 365 Business. Thanks to @Kulkul!

1 Like

I have the same issue and after I did the excel uninstall/re-install proces Excel.ReadFromFile node still doesn’t work. I already checked my register and I only have the 1.9 key. (I already did dynamo uninstall/re-install process). I read it could be due to excel file path so I copied a test file on my desktop from the office server but I still get the message “Excel.ReadFromFile operation failed”.

Any other suggestion?