work sheet state error

Issue #153 resolved
H zhy
created an issue

I want to get the state of a sheet which is hidden using sheet_state attribute, but it return visible which actually is hidden.

Comments (16)

  1. CharlieC

    Even with 2.0.3? and you'll need to differentiate between the sheets and rows and columns as they're handled by completely different bits of code. A file with empty sheets would be a great help in pinning down exactly what is not working as expected.

  2. Matthew Silver

    I used sheet.sheet_state != 'visible' to determine whether a sheet was hidden and row.row_dimension[1].visible for rows. For testing, I created a new Excel spreadsheet (.xlsx), made Sheet2 and Sheet3 hidden, and made the second line on Sheet1 hidden. I had the program print out sheet.sheet_state, and I got 'visible' for all three

  3. CharlieC

    Just pushed to 2.1 fixes for hidden rows and columns. Hidden sheets will take a bit more work - essentially refactor the related class to use descriptors to match the specification and add a parser for the sheet_state.

    3.4.1 (default, May 21 2014, 01:39:38) 
    [GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)]
    Python Type "help", "copyright", "credits" or "license" for more information.
    from openpyxl import load_workbook
    wb = load_workbook("Issues/bug153.xlsx")
    ws = wb.active
    ws.row_dimensions[2].hidden
    True
    
  4. Matthew Silver

    Hey Charlie,

    I pulled version 2.1 via mercurial, created a spreadsheet with hidden rows, tested for hidden rows by calling worksheet.row_dimensions[idx].hidden, and it still says hidden and visible rows alike are visible. The worksheet call, worksheet.sheet_state, also displays 'visible' for hidden worksheets. Would you be able to look into these issues?

  5. Log in to comment