openpyxl error

174 views
Skip to first unread message

Eric Telmer

unread,
Jul 23, 2011, 6:51:35 PM7/23/11
to python...@googlegroups.com
Hi when i try to load a workbook i get this error:

Traceback (most recent call last):
  File "<pyshell#72>", line 1, in <module>
    wb = load_workbook("861-2010-inventorycalculator.xlsm")
  File "C:\Python27\lib\openpyxl\reader\excel.py", line 81, in load_workbook
    raise e
NamedRangeException: Invalid named range string: "OFFSET('Custom Fuel Mix'!DynamicYear"

I think it has to do with the file itself but has anyone ever run into a similar error and knows what to do?
Thanks,
Eric

John Machin

unread,
Jul 24, 2011, 1:27:49 AM7/24/11
to python...@googlegroups.com
On Sunday, 24 July 2011 08:51:35 UTC+10, Eric Telmer wrote:
Hi when i try to load a workbook i get this error:

Traceback (most recent call last):
  File "<pyshell#72>", line 1, in <module>
    wb = load_workbook("861-2010-inventorycalculator.xlsm")
  File "C:\Python27\lib\openpyxl\reader\excel.py", line 81, in load_workbook
    raise e

Which version are you using? In the repository, that line in that file is not "raise e". In fact "raise e" is not in that file at all.

 
NamedRangeException: Invalid named range string: "OFFSET('Custom Fuel Mix'!DynamicYear"

It doesn't look like a valid anything -- it has an unmatched left parenthesis. DynamicYwear looks like a valid name for a range but the whole string looks like the start of a formula.

 

I think it has to do with the file itself but has anyone ever run into a similar error and knows what to do?



What software created the file? Does it open correctly with Excel 20nn? If so, when you look in the named ranges, what do you see?

You might be better off asking on https://groups.google.com/forum/#!forum/openpyxl-users .... Hint: sort out all the issues I've mentioned above (especially the version) first, to save them from asking you all over again.

HTH,
John

Eric Telmer

unread,
Jul 24, 2011, 2:38:35 PM7/24/11
to python...@googlegroups.com
Oh whoops I actually didnt post the entire error. Sorry But here it is.


Traceback (most recent call last):
  File "<pyshell#72>", line 1, in <module>
    wb = load_workbook("861-2010-inventorycalculator.xlsm")
  File "C:\Python27\lib\openpyxl\reader\excel.py", line 81, in load_workbook
    raise e
NamedRangeException: Invalid named range string: "OFFSET('Custom Fuel Mix'!DynamicYear"

--
You received this message because you are subscribed to the Google Groups "python-excel" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/python-excel/-/HO4JnRKJmVIJ.

To post to this group, send an email to python...@googlegroups.com.
To unsubscribe from this group, send email to python-excel...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/python-excel?hl=en-GB.

John Yeung

unread,
Jul 24, 2011, 3:05:31 PM7/24/11
to python...@googlegroups.com
On Sun, Jul 24, 2011 at 2:38 PM, Eric Telmer <erict...@gmail.com> wrote:
> Oh whoops I actually didnt post the entire error. Sorry But here it is.

Actually, you did post the whole error the first time. John Machin
only quoted up to the point of interest for his purposes.

Why don't you try answering John Machin's questions (so that it will
be easier for him or anyone else to help you), or following his
suggestion to ask for help on the forum devoted to openpyxl?

John Y.

Eric Telmer

unread,
Jul 24, 2011, 3:30:24 PM7/24/11
to python...@googlegroups.com
Thank you guys,
Im using version 1.5.1.And i dont know how these were created, i was just given them to work with. But I can open them. How do i look at the named ranges?
Thank you,
Eric

--
You received this message because you are subscribed to the Google Groups "python-excel" group.

John Machin

unread,
Jul 24, 2011, 7:42:56 PM7/24/11
to python...@googlegroups.com
On Monday, 25 July 2011 05:30:24 UTC+10, Eric Telmer wrote:
 
Im using version 1.5.1.And i dont know how these were created, i was just given them to work with. But I can open them. How do i look at the named ranges?


Click on "Formulas" then "Name Manager" .

Definitely raise this on the openpyxl-users forum. A "name" can refer to many things, e.g. pi -> 3.14, Boss -> "Mr Smith", Sales -> $A2:$Z$10, but openpyxl appears to want to believe that the names table can contain only named ranges ($A$2:$Z$10 is a range), not other things.

Chris Withers

unread,
Jul 26, 2011, 2:30:00 AM7/26/11
to python...@googlegroups.com, John Machin
On 25/07/2011 00:42, John Machin wrote:
> Definitely raise this on the openpyxl-users forum. A "name" can refer to
> many things, e.g. pi -> 3.14, Boss -> "Mr Smith", Sales -> $A2:$Z$10,
> but openpyxl appears to want to believe that the names table can contain
> only named ranges ($A$2:$Z$10 is a range), not other things.

Would the OP be better off with xlrd?
I can't remember if it supports named ranges or not...

Still, Mr Telmer hasn't exactly been forthcoming about his aims...

cheers,

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk

John Yeung

unread,
Jul 26, 2011, 8:42:32 AM7/26/11
to python...@googlegroups.com
On Tue, Jul 26, 2011 at 2:30 AM, Chris Withers <ch...@simplistix.co.uk> wrote:
> Would the OP be better off with xlrd?
> I can't remember if it supports named ranges or not...

The OP is trying to open .xlsm file, so for now needs openpyxl.
Perhaps he would be better off (generally) with xlsxrd, though....

John Y.

Chris Withers

unread,
Jul 26, 2011, 4:43:40 PM7/26/11
to python...@googlegroups.com, John Yeung

It would be great if that could just be merged into xlrd and put out in
the real world.

Mindyou, I find it somewhat frustrating that both xlrd and xlwt are
overdue a release by at least a year now. There's plenty on the trunk of
both packages that should be out there now...

John M. seems rather reluctant to reply to any mails from me, I really
have no idea why and I'm really not sure what to do...

Ideas?

Reply all
Reply to author
Forward
0 new messages