Closed
Description
Starting with openpyxl 2.2.0, various tests in pandas.io.tests.test_excel
fail with tracebacks similar to this one.
======================================================================
ERROR: test_basics_with_nan (pandas.io.tests.test_excel.Openpyxl2Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/pandas/io/tests/test_excel.py", line 1229, in wrapped
orig_method(self, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/pandas/io/tests/test_excel.py", line 641, in test_basics_with_nan
self.frame.to_excel(path, 'test1')
File "/usr/local/lib/python2.7/site-packages/pandas/core/frame.py", line 1267, in to_excel
startrow=startrow, startcol=startcol)
File "/usr/local/lib/python2.7/site-packages/pandas/io/excel.py", line 778, in write_cells
xcell.style = xcell.style.copy(**style_kwargs)
File "/usr/local/lib/python2.7/site-packages/openpyxl/styles/styleable.py", line 107, in style
protection=self.protection
File "/usr/local/lib/python2.7/site-packages/openpyxl/styles/__init__.py", line 42, in __init__
self._font = font
File "/usr/local/lib/python2.7/site-packages/openpyxl/descriptors/base.py", line 35, in __set__
raise TypeError('expected ' + str(self.expected_type))
TypeError: expected <class 'openpyxl.styles.fonts.Font'>
pandas.io.excel._Openpyxl2Writer.write_cells
uses openpyxl.styles.Style.copy
to merge newly specified style data with style data on existing cells. Sadly, the obvious workaround—iterate over the fields of the Style
object and use them to build an updated Style
object—won't work either without additional coddling, because the fields don't reliably return the native object that the Style
constructor demands.
>>> from openpyxl.styles import Style
>>> s0 = Style()
>>> s1 = Style(fill=s0.fill)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/obrienjw/venv/py27-openpyxl220/lib/python2.7/site-packages/openpyxl-2.2.0-py2.7.egg/openpyxl/styles/__init__.py", line 43, in __init__
self._fill = fill
File "/Users/obrienjw/venv/py27-openpyxl220/lib/python2.7/site-packages/openpyxl-2.2.0-py2.7.egg/openpyxl/descriptors/base.py", line 35, in __set__
raise TypeError('expected ' + str(self.expected_type))
TypeError: expected <class 'openpyxl.styles.fills.Fill'>
(See upstream issue: 444 copy() method on Style object raises TypeError)