expected type error since 2.5.0

Issue #967 resolved
JD Bothma
created an issue

The attached spreadsheet opened fine in 2.4.9, 2.4.10 and 2.4.11 but I get the following error in 2.5.0 if I open it writable:

Traceback (most recent call last):
  File "bin/epre.py", line 203, in <module>
    scrape_file(filepath, province_code, budget_financial_year)
  File "bin/epre.py", line 58, in scrape_file
    wb = load_workbook(filename=filename, data_only=True)
  File "/home/jdb/proj/code4sa/treasury-portal/fiscal-data-package/env/lib/python3.6/site-packages/openpyxl/reader/excel.py", line 274, in load_workbook
    for c in find_charts(archive, rel.target):
  File "/home/jdb/proj/code4sa/treasury-portal/fiscal-data-package/env/lib/python3.6/site-packages/openpyxl/chart/reader.py", line 43, in find_charts
    drawing = SpreadsheetDrawing.from_tree(tree)
  File "/home/jdb/proj/code4sa/treasury-portal/fiscal-data-package/env/lib/python3.6/site-packages/openpyxl/descriptors/serialisable.py", line 84, in from_tree
    obj = desc.expected_type.from_tree(el)
  File "/home/jdb/proj/code4sa/treasury-portal/fiscal-data-package/env/lib/python3.6/site-packages/openpyxl/descriptors/serialisable.py", line 84, in from_tree
    obj = desc.expected_type.from_tree(el)
  File "/home/jdb/proj/code4sa/treasury-portal/fiscal-data-package/env/lib/python3.6/site-packages/openpyxl/descriptors/serialisable.py", line 84, in from_tree
    obj = desc.expected_type.from_tree(el)
  [Previous line repeated 3 more times]
  File "/home/jdb/proj/code4sa/treasury-portal/fiscal-data-package/env/lib/python3.6/site-packages/openpyxl/descriptors/serialisable.py", line 100, in from_tree
    return cls(**attrib)
  File "/home/jdb/proj/code4sa/treasury-portal/fiscal-data-package/env/lib/python3.6/site-packages/openpyxl/drawing/shapes.py", line 104, in __init__
    self.lat = lat
  File "/home/jdb/proj/code4sa/treasury-portal/fiscal-data-package/env/lib/python3.6/site-packages/openpyxl/descriptors/base.py", line 44, in __set__
    raise TypeError('expected ' + str(self.expected_type))
TypeError: expected <class 'openpyxl.descriptors.base.Integer'>

It works fine when I open it readonly but I haven't figured out how to check if a row is hidden when readonly.

This is how I open it: https://github.com/OpenUpSA/treasury-data-package-pipeline/blob/01cdffdc0dd3eb75938d506d87029211c42c5995/bin/epre.py

Comments (3)

  1. CharlieC

    Thanks for the report. The problem is related to v 2.5 now being able to read charts. In order to do this it has to read the drawings.xml which not only contain links to the charts.xml but also inline drawings. Unfortunately openpyxl's support for DrawingML is incomplete and in some cases incorrect.

    You can either downgrade to 2.4.x or remove any drawings in the file until I can fix it.

  2. JD Bothma reporter

    Wow thanks for the very quick reply.

    I'm happy with sticking to a working version - I think I upgraded accidentally but I've pinned to 2.4.9

    All the best

  3. Log in to comment