Cannot load workbook

Issue #319 resolved
wlasowne created an issue

When i try to load workbook, i'm catch the exception

"__init__() got an unexpected keyword argument 'vertAlign'"

the issue in situation where /usr/local/lib/python2.7/dist-packages/openpyxl/reader/ in read_style_table try to read

 "<font><vertAlign val="superscript"/><sz val="10"/><color indexed="8"/><name val="Times New Roman"/><family val="1"/><charset val="204"/></font>" 

in styles.xml

Comments (24)

  1. CharlieC

    Thanks for the report and sorry for the error. Support for styles is better in 2.0 but we missed that and it wasn't caught in any tests because we don't have any examples. Do you happen to have a sample file we could use?

  2. CharlieC

    @wlasowne thanks. It's a big file and has found some other bugs in our code which is good.

    @ericgazoni this is an interesting file for all sorts of reasons. Not least NumberFormats. Looks like an OrderedList might be useful for them.

  3. CharlieC

    Looks like we drop the following number format:

    <numFmt numFmtId="43" formatCode="_-* #,##0.00_р_._-;\-* #,##0.00_р_._-;_-* "-"??_р_._-;_-@_-"/> Not sure if I want to try and support it! :-)

  4. Eric Gazoni

    it looks like a localized accounting format, but it's built-in. That's the typical issue we might land in: every localized version of Excel will have a different format number 43, following its regional rules, so there is no way we can "support" it without discriminating users not using this locale ...

    For me for instance, it is _ * #.##0,00_) _€_ ;_ * (#.##0,00) _€_ ;_ * "-"??_) _€_ ;_ @_

  5. CharlieC

    @ericgazoni I have a fix for reading these files in place but I've hit a bug in styles when it comes to writing relevant tests (preservation of some of the attributes). I think this is down to the some of the signature inspection stuff.

    from openpyxl.styles import Font
    from openpyxl.styles import Style
    st1 = Style()
    ft = Font(name='Calibri', charset=204, vertAlign='superscript')
    st2 = Style(font=ft)
    st1 == st2
    ft = Font(name='Calibri', charset=204, vertAlign='superscript', b=True)
    st3 = Style(font=ft)
    st1 == st3

    As things stand, fonts with additional values may be counted as the Default and, therefore, not serialised.

  6. CharlieC

    @wlasnowe If you can try the 2.0 branch you should be able to read your file okay. As noted in the discussion here, it doesn't quite save properly.

  7. CharlieC

    @wlasowne it's always better if you can test the branch before we make a release. Just spent a while chasing down some undocumented nastiness.

  8. CharlieC

    Just check out the project into a virtualenv with Mercurial as explained on the site, Something like this on unix style systems. Ask a grown-up for help if you're on Windows! ;-)

    hg clone 
    cd openpyxl
    hg up 2.0
    virtualenv .
    source bin/activate
    python develop
  9. wlasowne reporter

    The changes are in archive that i can get from main page? That archive is updated 48 minutes ago

  10. wlasowne reporter

    Nope. The problem is not resolve... You didn't add "vertAlign" in

    P.S.: in there are some strange string schema = String(allow_none=True) but in def init there are "scheme"

  11. CharlieC

    Good to hear it's working from you. When I was looking at the file that had passed through openpyxl it didn't look perfect but it looked okay. Looks like we can now preserve most of the formatting.

  12. Log in to comment