get_range_boundaries() range behaviour
Created originally on Bitbucket by stringfellow
The method openpyxl.worksheet.iter_worksheet.get_range_boundaries
has a curious default behaviour, which is to report the range of the columns as one greater than the given input, while reporting the row range as exactly that given:
#!python
In [10]: get_range_boundaries('A1')
Out[10]: (1, 1, 2, 1)
In [11]: get_range_boundaries('A1:B1')
Out[11]: (1, 1, 3, 1)
In [12]: get_range_boundaries('A1:B2')
Out[12]: (1, 1, 3, 2)
Notice that the max_col
is always one greater than the end of the true range, whereas the row conforms exactly to the given input. Also, the if/else
treats the max_col
result differently, using a magic + 1
for true range inputs and + column_offset
otherwise.
It seems that this behaviour is self-inconsistent at least, or could do with a docstring to explain the intent and purpose of it further.