-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error reading Excel workbook containing named formulas #218
Comments
You could probably fix it here: https://github.com/xlwings/xlwings-server/blob/main/app/static/js/core/xlwingsjs/xlwings.js#L282-L294 (book scope) or here: https://github.com/xlwings/xlwings-server/blob/main/app/static/js/core/xlwingsjs/xlwings.js#L347-L361 (sheet scope) |
Thanks for the quick response! Commenting out that loop worked for a short-term fix. Assuming the error originates there, wrapping it in a try-catch, skipping the problematic named items, and maybe warning the user somehow would probably be a better fix. I found debugging the office.js code a bit tough, there's very little information provided about the object being parsed. |
If you have an example of a named range that causes the failure, that would help to reproduce, thanks! |
To replicate: Go to the Name Manager and add the following Name:
|
…n line with workbook scoped named ranges)
OS (e.g. Windows 10 or macOS Sierra)
Windows 10
Versions of xlwings, Excel and Python (e.g. 0.11.8, Office 365, Python 3.7)
xlwings 0.33.3, Office 365, Python 3.12
Describe your issue (incl. Traceback!)
A JavaScript error is thrown when calling
xlwings.runPython(window.location.origin + "/end-point");
for my workbook. The error reads:Debugging the error in excel-win32.js leads me to believe that the cause is named references in my workbook.
The workbook contains numerous named references pointing to formulas like the following:
=OFFSET(BalancesByMonth!$B$4,0,0,COUNTA(BalancesByMonth!$B:$B)-1,COUNTA(BalancesByMonth!$5:$5))
.I can reproduce the error outside of xlwings by running the following in ScriptLab:
Which results in the same error. I've managed to find a couple stackoverflow posts similar issue such as https://stackoverflow.com/questions/78257772/excel-office-add-in-office-js-throws-error-when-trying-to-read-a-nameditems-r and https://stackoverflow.com/questions/70791127/evaluation-by-named-ranges-by-javascript-api-does-not-work-for-certain-formulas which seems to indicate that the operation
.getRange()
is not supported for certain named formulas.The problem appears to be that
xlwings.runPython
automatically callsgetRange()
on all named references, which doesn't work when the named references contain certain formulas.Is there a workaround or does this prevent me from using xlwings server until the issue is resolved?
The text was updated successfully, but these errors were encountered: