I have an existing code which uses pandas to read an excel workbook. It reads all the sheets including the hidden ones however, I want to read only the visible ones. Tried using this, but it didn't help:
The below are the snippets tried out.
xlFile = '/path/file_name.xlsx'
xl = pd.ExcelFile(xlFile)
list_of_visible_sheets = []
sheets = xl.book.sheets()
for sheet in sheets:
if sheet.visibility == 0:
list_of_visible_sheets.append(sheets)
print(list_of_visible_sheets)
and
list_of_visible_sheets = []
sheets = xl.sheet_names
for sheet in sheets:
if sheet.visibility == 0:
list_of_visible_sheets.append(sheets)
print(list_of_visible_sheets)
How can I get the visible sheets alone?