Skip to content

Commit 9bcf2a1

Browse files
committed
feat: If reset_dimensions is set, recalculate the worksheet's dimensions. Only reset dimensions if read_only is set.
1 parent 68922e4 commit 9bcf2a1

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

CHANGELOG.rst

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
Unreleased
2-
----------
1+
0.3.0 - October 30, 2023
2+
------------------------
33

4+
* If the ``reset_dimensions`` argument to :meth:`.Table.from_xlsx` is set, recalculate the worksheet's dimensions, instead of assuming that the table's width matches the first row's.
5+
* The ``reset_dimensions`` argument to :meth:`.Table.from_xlsx` is ignored if the ``read_only`` argument is false.
46
* Add Python 3.8, 3.9, 3.10, 3.11, 3.12 support.
57
* Drop support for 3.5 (2020-09-13), 3.6 (2021-12-23), 3.7 (2023-06-27).
68

agateexcel/table_xlsx.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ def from_xlsx(cls, path, sheet=None, skip_lines=0, header=True, read_only=True,
2525
The number of rows to skip from the top of the sheet.
2626
:param header:
2727
If :code:`True`, the first row is assumed to contain column names.
28+
:param read_only:
29+
If :code:`True`, the XLSX file is opened in read-only mode, to reduce
30+
memory consumption.
2831
:param reset_dimensions:
2932
If :code:`True`, do not trust the dimensions in the file's properties,
3033
and recalculate them based on the data in the file.
@@ -69,8 +72,9 @@ def from_xlsx(cls, path, sheet=None, skip_lines=0, header=True, read_only=True,
6972
offset = 0
7073
rows = []
7174

72-
if reset_dimensions:
75+
if read_only and reset_dimensions:
7376
sheet.reset_dimensions()
77+
sheet.calculate_dimension(force=True)
7478

7579
if header:
7680
sheet_header = sheet.iter_rows(min_row=1 + skip_lines, max_row=1 + skip_lines)

docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
project = 'agate-excel'
1414
copyright = '2017, Christopher Groskopf'
15-
version = '0.2.5'
15+
version = '0.3.0'
1616
release = version
1717

1818
# -- General configuration ---------------------------------------------------

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name='agate-excel',
8-
version='0.2.5',
8+
version='0.3.0',
99
description='agate-excel adds read support for Excel files (xls and xlsx) to agate.',
1010
long_description=long_description,
1111
long_description_content_type='text/x-rst',

0 commit comments

Comments
 (0)