Conditionnal formatting is assuming that values are int.

Issue #539 resolved
Mathieu Gueydan
created an issue

In openpyxl / openpyxl / formatting / rule.py , on line 31 One may find this :

    val = Integer(allow_none=True)

But, when I open an xslx file, I may find this : openpyxl_MEFC_1.png

Or even this : openpyxl_MEFC_2.png

Loading one of those files with openpyxl induce this kind of trace:

expected <class 'float'>
Traceback (most recent call last):
  File "Lib\openpyxl\descriptors\base.py", line 55, in _convert
ValueError: could not convert string to float: '($Z$17*100)'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "./DOFormat\entryPoint.py", line 61, in generateTree
    backlog += AEBTFuncTree2Xls().generate("c:\\tmp\\template.xlsx", outputfilepath+".xlsx", tupleRoot)
  File "./DOFormat\aebtFuncTree2Xls.py", line 15, in generate
    wb = load_workbook(outputfilepath)
  File "Lib\openpyxl\reader\excel.py", line 233, in load_workbook
  File "Lib\openpyxl\reader\worksheet.py", line 104, in parse
  File "Lib\openpyxl\reader\worksheet.py", line 267, in parser_conditional_formatting
  File "Lib\openpyxl\descriptors\serialisable.py", line 65, in from_tree
  File "Lib\openpyxl\descriptors\serialisable.py", line 65, in from_tree
  File "Lib\openpyxl\descriptors\serialisable.py", line 78, in from_tree
  File "Lib\openpyxl\formatting\rule.py", line 42, in __init__
  File "Lib\openpyxl\descriptors\base.py", line 67, in __set__
  File "Lib\openpyxl\descriptors\base.py", line 57, in _convert
TypeError: expected <class 'float'>

Comments (5)

  1. Charlie Clark

    Okay. I can reproduce this. I think the problem comes from mixing the existing API with the underlying specification of the file format, which is particularly poor in this area. All the examples we've had so far always used numbers.

  2. Log in to comment