ValueError: Value does not match pattern [0-9a-fA-F]+$

1,733 views
Skip to first unread message

j...@afb.de

unread,
Jul 4, 2017, 2:47:00 AM7/4/17
to openpyxl-users
Hi,

I try to read a excel file and get the error "ValueError: Value does not match pattern [0-9a-fA-F]+$". The Stacktrace is this:

Traceback (most recent call last):
  File "./teamplanung_reader.py", line 324, in <module>
    main()
  File "./teamplanung_reader.py", line 108, in main
    excel = load_workbook(excelfile, data_only=True)  # Formula executed
  File "/usr/lib/python2.7/site-packages/openpyxl/reader/excel.py", line 186, in load_workbook
    parser.parse()
  File "/usr/lib/python2.7/site-packages/openpyxl/packaging/workbook.py", line 47, in parse
    package = WorkbookPackage.from_tree(node)
  File "/usr/lib/python2.7/site-packages/openpyxl/descriptors/serialisable.py", line 79, in from_tree
    obj = desc.expected_type.from_tree(el)
  File "/usr/lib/python2.7/site-packages/openpyxl/descriptors/serialisable.py", line 92, in from_tree
    return cls(**attrib)
  File "/usr/lib/python2.7/site-packages/openpyxl/workbook/protection.py", line 112, in __init__
    self.hashValue = hashValue
  File "/usr/lib/python2.7/site-packages/openpyxl/descriptors/base.py", line 255, in __set__
    raise ValueError('Value does not match pattern {0}'.format(self.pattern))
ValueError: Value does not match pattern [0-9a-fA-F]+$


Any suggestions how to get the origin of the error? 

I tried to debug it and it seams to be happend on a cell with a german umlaut 'ö' in it. Can case this the error while opening the excel file?

Regards,
Julian

Charlie Clark

unread,
Jul 4, 2017, 3:19:33 AM7/4/17
to openpyx...@googlegroups.com
Am .07.2017, 08:47 Uhr, schrieb <j...@afb.de>:

> Any suggestions how to get the origin of the error?
> I tried to debug it and it seams to be happend on a cell with a
> german umlaut 'ö' in it. Can case this the error while opening the excel
> file?

The error looks like it's coming from the WorkbookProtection part of the
file.

If you unzip the Excel file (all Excel files are zip archives) and look at
the workbook.xml file you should be able to see the relevant section.

Charlie
--
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Kronenstr. 27a
Düsseldorf
D- 40217
Tel: +49-211-600-3657
Mobile: +49-178-782-6226

j...@afb.de

unread,
Jul 4, 2017, 9:16:10 AM7/4/17
to openpyxl-users
Hi,

while I get a new copy of the excel file the error seams to be fixed (someone updated the file) and I can not reproduce the error. Maybe the next time I have this issue (it was the second time I had this problem), I will go back to this mailing list.

Thanks for your help!

Regards
Julian

to...@largecoffee.com

unread,
Nov 16, 2017, 12:40:23 PM11/16/17
to openpyxl-users
I wound up on this page because I was getting the same error. Re-saving the file with a different Excel did solve the problem, but the client wasn't real happy with that solution.

Clients, sheesh, amiright??

On Charlie's recommendation, I unzipped the file and had a poke around in workbook.xml. The offending line was here....

<fileSharing userName="My Username" algorithmName="SHA-512" hashValue="BkDLxsVAwbJ7dlt+lt8ljNk1loep7UFHDtcypQcCFGyPuiG0VT+j33Vn7UVVpA5qh0UnANoWlrj7x2ZgXrtU9w==" saltValue="LcAE4uGJfnJNeVTU9BD//Q==" spinCount="100000"/>

I removed the references to algo, hash, salt, spin, re-zipped and everything was right in the universe.

Charlie Clark

unread,
Nov 16, 2017, 1:27:56 PM11/16/17
to openpyx...@googlegroups.com
Am .11.2017, 18:40 Uhr, schrieb <to...@largecoffee.com>:

> I wound up on this page because I was getting the same error. Re-saving
> the
> file with a different Excel did solve the problem, but the client wasn't
> real happy with that solution.
> Clients, *sheesh*, amiright??
> On Charlie's recommendation, I unzipped the file and had a poke around in
> workbook.xml. The offending line was here....
> <fileSharing userName="My Username" algorithmName="SHA-512"
> hashValue="BkDLxsVAwbJ7dlt+lt8ljNk1loep7UFHDtcypQcCFGyPuiG0VT+j33Vn7UVVpA5qh0UnANoWlrj7x2ZgXrtU9w=="
> saltValue="LcAE4uGJfnJNeVTU9BD//Q==" spinCount="100000"/>
> I removed the references to algo, hash, salt, spin, re-zipped and
> everything was right in the universe.

Glad that got it working for you. For what it's worth it's now probably
possible to remove the object in openpyxl. Being able to remove protection
like this highlights how pointless it is to try and doll it up with
fancier hashing algorithms.

to...@largecoffee.com

unread,
Nov 16, 2017, 1:48:21 PM11/16/17
to openpyxl-users
Is there any way to disable this "feature" at the Excel level rather than having to go through the unzip routine?

Charlie Clark

unread,
Nov 17, 2017, 4:16:55 AM11/17/17
to openpyx...@googlegroups.com
Am .11.2017, 19:48 Uhr, schrieb <to...@largecoffee.com>:

> Is there any way to disable this "feature" at the Excel level rather than
> having to go through the unzip routine?

Sure, except I don't Excel for MacOS properly supports them so I can't
really help. This might be what you're looking for:

https://support.office.com/en-us/article/Protect-a-workbook-7e365a4d-3e89-4616-84ca-1931257c1517
Reply all
Reply to author
Forward
0 new messages