Unable to save file from workbook based on file that contains colored tabs

Issue #508 resolved
Michael Perreux
created an issue

Reproducing the issue:

Create xlsx with colored tabs save as hello.xlsx.

Run following code:

from openpyxl import load_workbook

wb = load_workbook("hello.xlsx")
wb.save("hello2.xlsx")
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/xml/etree/ElementTree.py", line 1081, in _escape_attrib
    if "&" in text:
TypeError: argument of type 'int' is not iterable

During handling of the above exception, another exception occurred:
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/xml/etree/ElementTree.py", line 1059, in _raise_serialization_error
    "cannot serialize %r (type %s)" % (text, type(text).__name__)
TypeError: cannot serialize 7 (type int)

Comments (13)

  1. Charlie Clark

    I can't reproduce the problem with a file with coloured tabs and the error message suggests the problem might be something else. Can you please supply the full traceback?

  2. cooking mamut

    Having the same error here with python 2.7.8 and openpyxl 2.2.5. With and without lxml installed.

    ... File "lxml.etree.pyx", line 2912, in lxml.etree.Element (src\lxml\lxml.etree.c:68681) File "apihelpers.pxi", line 140, in lxml.etree._makeElement (src\lxml\lxml.etree.c:15242) File "apihelpers.pxi", line 128, in lxml.etree._makeElement (src\lxml\lxml.etree.c:15125) File "apihelpers.pxi", line 275, in lxml.etree._initNodeAttributes (src\lxml\lxml.etree.c:16719) File "apihelpers.pxi", line 297, in lxml.etree._addAttributeToNode (src\lxml\lxml.etree.c:17192) File "apihelpers.pxi", line 1391, in lxml.etree._utf8 (src\lxml\lxml.etree.c:27100) TypeError: Argument must be bytes or unicode, got 'long'

    Here is a sample file. Just an empty file with a colored tab http://s000.tinyupload.com/index.php?file_id=86372281751529079374

  3. Sergii_Potapov

    Hi Charlie,

    I'm not sure that bug is fixed. Please find color_bug.xlsx attached.

    Steps to reproduce: 1. file was created in MS office 2010 2. the first sheet was colored by standard olive green color (see snapshot) and saved\closed 3. open the file and save by code:

    import openpyxl
    wb = openpyxl.load_workbook('color_bug.xlsx', data_only=True)
    
    wb.save('caramba.xlsx')
    

    Result: TypeError: cannot serialize 6 (type int)

  4. Log in to comment