The attributes you are looking for are inside the column_dimensions
and row_dimensions
attributes of the Worksheet
object.
These are bound dictionaries whose values are ColumnDimension
/RowDimension
objects. The specific attribute you're looking for is ColumnDimension.hidden
.
The following will print the column letter of all hidden columns in worksheet ws
:
for colLetter,colDimension in ws.column_dimensions.items():
if colDimension.hidden == True:
print(colLetter)
And for rows:
for rowNum,rowDimension in ws.row_dimensions.items():
if rowDimension.hidden == True:
print(rowNum)
As I understand it, loading your workbook as read_only
can mess with ws.row_dimensions
, so be careful in this case.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…