From d4bd195b680a19e36d86d4bb8849fbd5670a8444 Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Tue, 7 Nov 2023 13:47:45 -0500 Subject: [PATCH] feat: Recalculate dimensions if reported as A1:A1 --- CHANGELOG.rst | 5 +++++ agateexcel/table_xlsx.py | 4 ++-- docs/conf.py | 2 +- setup.py | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e4ac087..86d6f5b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,8 @@ +0.4.0 - November 7, 2023 +------------------------ + +* The ``reset_dimensions`` argument to :meth:`.Table.from_xlsx` defaults to ``None`` instead of ``False``. If ``reset_dimensions`` is ``None``, and if the worksheet's dimensions are ``A1:A1``, recalculate the worksheet's dimensions. To disable this behavior, set ``reset_dimensions`` to ``False``. + 0.3.0 - October 30, 2023 ------------------------ diff --git a/agateexcel/table_xlsx.py b/agateexcel/table_xlsx.py index cec29b7..da7b4bc 100644 --- a/agateexcel/table_xlsx.py +++ b/agateexcel/table_xlsx.py @@ -12,7 +12,7 @@ def from_xlsx(cls, path, sheet=None, skip_lines=0, header=True, read_only=True, - reset_dimensions=False, row_limit=None, **kwargs): + reset_dimensions=None, row_limit=None, **kwargs): """ Parse an XLSX file. @@ -72,7 +72,7 @@ def from_xlsx(cls, path, sheet=None, skip_lines=0, header=True, read_only=True, offset = 0 rows = [] - if read_only and reset_dimensions: + 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) diff --git a/docs/conf.py b/docs/conf.py index 8870729..f82fc3b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -12,7 +12,7 @@ project = 'agate-excel' copyright = '2017, Christopher Groskopf' -version = '0.3.0' +version = '0.4.0' release = version # -- General configuration --------------------------------------------------- diff --git a/setup.py b/setup.py index 09ebdb1..995aa83 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name='agate-excel', - version='0.3.0', + version='0.4.0', description='agate-excel adds read support for Excel files (xls and xlsx) to agate.', long_description=long_description, long_description_content_type='text/x-rst',