From fb24ccb144823de9e3f91919f47101fe03b1fd36 Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Tue, 7 Nov 2023 14:19:39 -0500 Subject: [PATCH] fix: Work around openpyxl behavior --- agateexcel/table_xlsx.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/agateexcel/table_xlsx.py b/agateexcel/table_xlsx.py index da7b4bc..aa62f69 100644 --- a/agateexcel/table_xlsx.py +++ b/agateexcel/table_xlsx.py @@ -73,8 +73,12 @@ def from_xlsx(cls, path, sheet=None, skip_lines=0, header=True, read_only=True, rows = [] if read_only and (reset_dimensions or reset_dimensions is None and sheet.calculate_dimension() == 'A1:A1'): - sheet.reset_dimensions() - sheet.calculate_dimension(force=True) + try: + sheet.reset_dimensions() + sheet.calculate_dimension(force=True) + # https://foss.heptapod.net/openpyxl/openpyxl/-/issues/2111 + except UnboundLocalError: + pass if header: sheet_header = sheet.iter_rows(min_row=1 + skip_lines, max_row=1 + skip_lines)