Skip to content Skip to sidebar Skip to footer

How Can I Find The Last Non-empty Row Of Excel Using Openpyxl 3.03?

How can I find the number of the last non-empty row of an whole xlsx sheet using python and openpyxl? The file can have empty rows between the cells and the empty rows at the end c

Solution 1:

# Open file with openpyxl
to_be = load_workbook(FILENAME_xlsx)
s = to_be.active

last_empty_row = len(list(s.rows))
print(last_empty_row)
## Output: 13

s.rows is a generator and its list contains arrays of each rows cells.


Post a Comment for "How Can I Find The Last Non-empty Row Of Excel Using Openpyxl 3.03?"