xlsx reader should return the freeze_panes

Issue #215 resolved
Guido Draheim
created an issue

The xlsx writer can write worksheet.freeze_panes but they will not be returned in the variable by the xlsx reader.

The fix is rather trivial. I had needed it for my project, so here is the patch.

Comments (9)

  1. CharlieC

    @guidod I think Eric prefers pull requests and this looks like new code without test coverage. My ElementTree stuff isn't brilliant but this use of find(QName().text) reminds me of a problem we had with headers and footers which failed with empty tags because the search returns a node not the text. Be worth checking (and adding a test) that that can't happen here either.

  2. Guido Draheim reporter

    The result of find() is always checked on None and there is no element text but an attribute "topLeftCell" to be read into ws.freeze_panes.

    I have created a testcase here and it revealed a typo (page <-> pane) in the old patch. As I am not fluent with the test structure of openpyxl I have put it on a classic unittest basis with a simple workbook saved to a file to make up the preconditions. For testing you would need to go to openpyxl/tests and run "python test_freeze.py". Feel free to edit the Testclass to blend it with the others.

    pushing patch 2

  3. CharlieC

    See #201 for the related coding issue that seems to be provoked by LibreOffice. Not sure whether it's relevant here but might be worth opening and saving a sample file with LibreOffice to see that the same issue doesn't crop up.

    noseis used as testrunner and by many tests. Tests look okay but what's with the manipulation of sys.path?

  4. Guido Draheim reporter

    That sys.path handling is wrapped in if-main so it does not hit within a nosetest collector (I have just checked that - nose imports the file as a module so the __main__ parts are not included). It is required however - if you do not put the local development package on the sys.path then you are going to test the global installation of openpyxl which is rightout wrong.

    The problem of #201 is not possible here as all code paths are wrapped with is-None checks and the only equals-test is fine with testing a string against None. Note that I am only working on Linux and my test viewer is LibreOffice - I didn't spot any problems so far (although my library bitbucket.org/guidod/easyxf does only use a limited set of features from openpyxl).

  5. CharlieC

    You're right: adding read support for sheetViews (including freezes) should be trivial (since the WorksheetParser was refactored to be more modular). A pull request based on the 2.1 branch would still be welcome.

  6. Log in to comment