How to detect hidden rows in excel document using Openpyxl

Question:

Is possible to detect when a row is hidden in an EXCEL (*.xlsx) document reads with Openpyxl?

...
wb_obj = openpyxl.load_workbook(path)
ws = wb_obj.get_sheet_by_name(page)

for row_num in range(first_row, ws.max_row + 1):
    # Need to check here if a row is hidden (ex: its height is 0)
    # ws.row_dimensions[row_num].height -> Is always None (Not useful to me)
...
Asked By: Dan A.S.

||

Answers:

The answer I was looking for:

worksheet.row_dimensions[row_number].hidden

wb_obj = openpyxl.load_workbook(path)
ws = wb_obj.get_sheet_by_name(page)

for row_num in range(first_row, ws.max_row + 1):
     # is this row hidden?
     if row_num in wx.row_dimensions and ws.row_dimensions[row_num].hidden:
         print('The row {} is hidden'.format(row_num))
Answered By: Dan A.S.
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.