get_highest_row(), get_highest_column() changes after .cell() calls

Issue #176 wontfix
Michael Scovetta created an issue

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()
>>> s.get_highest_column()

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()
>>> s.get_highest_column()

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().

Comments (6)

  1. Eric Gazoni

    this is the intended behavior, as the cell is created when you try to access a cell that does not exist yet. It's also specified in the docs not to look for cells you don't plan to use ;-)

  2. Log in to comment