Skip to content
This repository has been archived by the owner on Aug 3, 2021. It is now read-only.

Make calculate_dimension more pythonic if we can #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions openpyxl/worksheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,11 @@ def get_highest_column(self):

def calculate_dimension(self):
"""Return the minimum bounding range for all cells containing data."""
return 'A1:%s%d' % (get_column_letter(self.get_highest_column()),
self.get_highest_row())
try:
return f"{get_column_letter(min_col)}{min_row}:{get_column_letter(max_col)}{max_row}"
except:
return 'A1:%s%d' % (get_column_letter(self.get_highest_column()),
self.get_highest_row())

def range(self, range_string, row = 0, column = 0):
"""Returns a 2D array of cells, with optional row and column offsets.
Expand Down