Am 06.06.2013, 21:27 Uhr, schrieb Charlie Clark
<
charli...@clark-consulting.eu>:
> I'll try and have a look at this over the weekend as it sounds like a
> bug.
Yes, this is a bug. It looks like openpyxl cannot handle some empty tags.
From the source:
<headerFooter differentFirst="false" differentOddEven="false">
<oddHeader/>
<oddFooter/>
</headerFooter>
The relevant code in reader/worksheet.py
https://bitbucket.org/ericgazoni/openpyxl/src/bbf6f57f094eab319d57c009e4ac21fb9fad5815/openpyxl/reader/worksheet.py?at=default#cl-207
headerFooter = root.find(QName(xmlns, 'headerFooter').text)
if headerFooter is not None:
oddHeader = headerFooter.find(QName(xmlns, 'oddHeader').text)
if oddHeader is not None:
ws.header_footer.setHeader(oddHeader.text)
oddFooter = headerFooter.find(QName(xmlns, 'oddFooter').text)
if oddFooter is not None:
ws.header_footer.setFooter(oddFooter.text)
A quick fix is to adjust the conditions for oddHeader and oddFooter to
refer to their text attributes.
if oddHeader.text is not None:…
A quick check indicates that this does not break any tests, however, I
suspect that is simply because there are no tests for it. fast_parse() is
one of the more monolithic methods for which writing tests is not much
fun. I'll submit a bug on this and see if it can't be refactored a bit to
make it more testable.