InvalidFileException for missing theme (1.6.1)

Issue #160 resolved
Former user created an issue

Sometimes I receive workbooks that are missing a theme, a condition that was not apparent in OpenPyXL 1.5.8 and raises an exception in 1.6.1:

    openpyxl.shared.exc.InvalidFileException: "There is no item named
        'xl/theme/theme1.xml' in the archive"

Since the writer checks for loaded_theme, it doesn't seem as though a workaround would hurt in the reader (the assertion below is only for emphasis):

    > hg diff -U0 --nodates openpyxl/reader/
    diff -r 94b05cf9defb openpyxl/reader/
    --- a/openpyxl/reader/
    +++ b/openpyxl/reader/
    @@ -137,1 +137,7 @@
    -    wb.loaded_theme =
    +    try:
    +        wb.loaded_theme =
    +    except KeyError:
    +        # Respect self.loaded_theme = None
    +        assert wb.loaded_theme == None

loaded_theme and its use of ARC_THEME looks like a feature (rather than a requirement) added in rev 64abb80fb7d2.

Comments (8)

  1. Justin Myers

    My particular file was a Google Drive spreadsheet downloaded as xlsx rather than one generated by Excel proper, but I'm also seeing this behavior in 1.6.1 and not 1.5.8.

  2. Log in to comment