Hidden (grouped out) rows/columns at the end of worksheets are not registered as hidden.

Issue #1338 new
Angelina Li created an issue

While working on a project, I noticed that when there are rows or columns containing data that are hidden and are the very end of a worksheet, those rows / columns are registered as not hidden. I’ve attached a workbook and a script that demonstrates this effect. This is pretty annoying for, e.g., reading and manipulating data in only columns that are visible. Let me know if I can explain the problem further.

Contents of test_script.py are pasted below:

import openpyxl

wb = openpyxl.load_workbook("test_file.xlsx")
ws = wb.active

columns = ["A", "B", "C", "D", "E", "F"]
expected_hidden = [False, True, False, True, True, True]
actual_hidden = [ws.column_dimensions[col].hidden for col in columns]

for i, col in enumerate(columns):
    if expected_hidden[i] != actual_hidden[i]:
        print("ERROR col '{}': Expected column hidden == {}, but actual column hidden == {}".format(
            col, expected_hidden[i], actual_hidden[i]))

"""
output:

$ py test_script.py
ERROR col 'E': Expected column hidden == True, but actual column hidden == False
ERROR col 'F': Expected column hidden == True, but actual column hidden == False
"""

Comments (0)

  1. Log in to comment