theorchard / openpyxl

Other
58 stars 21 forks source link

openpyxl hides two columns instead of 1 #24

Open JasonMendoza2008 opened 1 year ago

JasonMendoza2008 commented 1 year ago

Here is a MRE. Download huge_bug.xlsx first:

from openpyxl import load_workbook

document = load_workbook("huge_bug.xlsx")

# hide column AJ
document.active.column_dimensions["AJ"].hidden = True

# save workbook
document.save("huge_bug_2.xlsx")

I want to hide column AJ but both columns AJ and AK get hidden and I have no idea why. There is no merged cell that could indicate why those two columns "work together".

The problem might be from my initial excel file, but I'm not sure where to look; however it does look like an openpyxl problem because it doesn't occur with VBA.

I'm using openpyxl 3.0.10 and Python 3.11.1.

As @moken pointed out on SO, it probably has to do with the "fill" of the columns, if you change one of them, only by one point, the bug is not reproducible anymore.