Conditionnal formatting is assuming that values are int.

Issue #539 resolved
Mathieu Gueydan
created an issue

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

    val = Integer(allow_none=True)

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

Or even this :

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

expected <class 'float'>
Traceback (most recent call last):
  File "Lib\openpyxl\descriptors\", 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\", line 61, in generateTree
    backlog += AEBTFuncTree2Xls().generate("c:\\tmp\\template.xlsx", outputfilepath+".xlsx", tupleRoot)
  File "./DOFormat\", line 15, in generate
    wb = load_workbook(outputfilepath)
  File "Lib\openpyxl\reader\", line 233, in load_workbook
  File "Lib\openpyxl\reader\", line 104, in parse
  File "Lib\openpyxl\reader\", line 267, in parser_conditional_formatting
  File "Lib\openpyxl\descriptors\", line 65, in from_tree
  File "Lib\openpyxl\descriptors\", line 65, in from_tree
  File "Lib\openpyxl\descriptors\", line 78, in from_tree
  File "Lib\openpyxl\formatting\", line 42, in __init__
  File "Lib\openpyxl\descriptors\", line 67, in __set__
  File "Lib\openpyxl\descriptors\", line 57, in _convert
TypeError: expected <class 'float'>

Comments (7)

  1. CharlieC

    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