More efficient Worksheet methods: min_row, max_row, min_column, max_column
Existing implementation is building a set of all distinct row/column numbers, which is not necessary. We can make it much faster like this:
@property
def min_row(self):
"""The minimium row index containing data (1-based)
:type: int
"""
min_row = 1
if self._cells:
min_row = min(c[0] for c in self._cells)
return min_row
@property
def max_row(self):
"""The maximum row index containing data (1-based)
:type: int
"""
max_row = 1
if self._cells:
max_row = max(c[0] for c in self._cells)
return max_row
@property
def min_column(self):
"""The minimum column index containing data (1-based)
:type: int
"""
min_col = 1
if self._cells:
min_col = min(c[1] for c in self._cells)
return min_col
@property
def max_column(self):
"""The maximum column index containing data (1-based)
:type: int
"""
max_col = 1
if self._cells:
max_col = max(c[1] for c in self._cells)
return max_col