Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility issue with openpyxl 3.1.0 - read_sheet - TypeError: 'set' object is not subscriptable #52

Open
chel-ou opened this issue Feb 5, 2023 · 6 comments · May be fixed by #53
Open

Comments

@chel-ou
Copy link

chel-ou commented Feb 5, 2023

Recent update of openpyxl to 3.1.0 breaks read_sheet.

Below is the traceback

Traceback (most recent call last):
  File "/code/base/tests/tests.py", line 3318, in test_sheet
    sheet = pe.get_sheet(
  File "/opt/project/.venv/lib/python3.10/site-packages/pyexcel/core.py", line 37, in get_sheet
    named_content = sources.get_sheet_stream(**keywords)
  File "/opt/project/.venv/lib/python3.10/site-packages/pyexcel/internal/core.py", line 21, in get_sheet_stream
    sheets = a_source.get_data()
  File "/opt/project/.venv/lib/python3.10/site-packages/pyexcel/plugins/sources/memory_input.py", line 40, in get_data
    sheets = self.__parser.parse_file_content(
  File "/opt/project/.venv/lib/python3.10/site-packages/pyexcel/plugins/parsers/excel.py", line 27, in parse_file_content
    return self._parse_any(
  File "/opt/project/.venv/lib/python3.10/site-packages/pyexcel/plugins/parsers/excel.py", line 40, in _parse_any
    sheets = get_data(anything, file_type=file_type, **keywords)
  File "/opt/project/.venv/lib/python3.10/site-packages/pyexcel_io/io.py", line 86, in get_data
    data, _ = _get_data(
  File "/opt/project/.venv/lib/python3.10/site-packages/pyexcel_io/io.py", line 105, in _get_data
    return load_data(**keywords)
  File "/opt/project/.venv/lib/python3.10/site-packages/pyexcel_io/io.py", line 205, in load_data
    result = reader.read_all()
  File "/opt/project/.venv/lib/python3.10/site-packages/pyexcel_io/reader.py", line 95, in read_all
    content_dict = self.read_sheet_by_index(sheet_index)
  File "/opt/project/.venv/lib/python3.10/site-packages/pyexcel_io/reader.py", line 84, in read_sheet_by_index
    sheet_reader = self.reader.read_sheet(sheet_index)
  File "/opt/project/.venv/lib/python3.10/site-packages/pyexcel_xlsx/xlsxr.py", line 148, in read_sheet
    sheet = SlowSheet(native_sheet, **self.keywords)
  File "/opt/project/.venv/lib/python3.10/site-packages/pyexcel_xlsx/xlsxr.py", line 72, in __init__
    for ranges in sheet.merged_cells.ranges[:]:

TypeError: 'set' object is not subscriptable

Pinning version of openpyxl to 3.0.10 is a temporary workaround.

@konstista
Copy link

konstista commented Feb 7, 2023

@chfw sorry for ping and thanks for your amazing work!

This line here:
for ranges in sheet.merged_cells.ranges[:]:

Should probably be replaced with:
for ranges in list(sheet.merged_cells.ranges)[:]:

For everyone who is struggling, here are your requirements.txt:

pyexcel==0.6.7
pyexcel-xlsx==0.6.0
openpyxl==3.0.10

@peter279k
Copy link

@chfw sorry for ping and thanks for your amazing work!

This line here: for ranges in sheet.merged_cells.ranges[:]:

Should probably be replaced with: for ranges in list(sheet.merged_cells.ranges)[:]:

For everyone who is struggling, here are your requirements.txt:

pyexcel==0.6.7
pyexcel-xlsx==0.6.0
openpyxl==3.0.10

Thanks! Your comment is very helpful for me!

craiga added a commit to craiga/pyexcel-xlsx that referenced this issue May 1, 2023
craiga added a commit to craiga/pyexcel-xlsx that referenced this issue May 1, 2023
@craiga craiga linked a pull request May 1, 2023 that will close this issue
6 tasks
@kodurusivakumar34
Copy link

May i know ,any update on this issue?

@kristianperkins
Copy link

Looks like this is causing problems with downstream applications and maintainers are warning against using pyexcel because breaking changes aren't being fixed (see above linked issues).

@stuchalk
Copy link

stuchalk commented Mar 14, 2024

Also not working with macOS Ventura 13.6.4 Excel v16.83. Python 3.11.8.

kennedykori added a commit to savannahghi/mentorship-xls-form that referenced this issue Jun 4, 2024
Change the supported Python version from py310 to py312.

Upgrade all dependencies except [openpyxl](https://openpyxl.readthedocs.io/en/stable/).
See [this issue](pyexcel/pyexcel-xlsx#52) for
details.
saladgg pushed a commit to savannahghi/mentorship-xls-form that referenced this issue Jun 4, 2024
Change the supported Python version from py310 to py312.

Upgrade all dependencies except [openpyxl](https://openpyxl.readthedocs.io/en/stable/).
See [this issue](pyexcel/pyexcel-xlsx#52) for
details.
@TheDuckGoesQuark
Copy link

@chfw sorry for ping and thanks for your amazing work!

This line here: for ranges in sheet.merged_cells.ranges[:]:

Should probably be replaced with: for ranges in list(sheet.merged_cells.ranges)[:]:

For everyone who is struggling, here are your requirements.txt:

pyexcel==0.6.7
pyexcel-xlsx==0.6.0
openpyxl==3.0.10

This failed for me saying that version pyexcel 0.6.7 doesn't exist, but just pinning the openpyxl version to 3.0.10 worked 😄

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants