If we open a worksheet with 5 columns and 10 rows:
>>> w = openpyxl.load_workbook('testcase.xlsx') >>> s = get_sheet_by_name('Sheet1') >>> s.get_highest_row() 10 >>> s.get_highest_column() 5
If we read a cell out of bounds:
>>> s.cell(row=70, column=70) <Cell Sheet1:BS71>
And then read the highest row or column, we get:
>>> s.get_highest_row() 71 >>> s.get_highest_column() 71
I don't see why this would be expected behavior, especially since the cell returned (Sheet1:BS71) hasn't been modified.
The workaround is to read the get_highest_row() and get_highest_column() before calling .cell().