UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)

Issue #842 resolved
jefffffrey
created an issue
  File "/home/jeffrey/workspace/romulan-env/local/lib/python2.7/site-packages/openpyxl/workbook/workbook.py", line 345, in save
    save_workbook(self, filename)
  File "/home/jeffrey/workspace/romulan-env/local/lib/python2.7/site-packages/openpyxl/writer/excel.py", line 266, in save_workbook
    writer.save(filename)
  File "/home/jeffrey/workspace/romulan-env/local/lib/python2.7/site-packages/openpyxl/writer/excel.py", line 248, in save
    self.write_data()
  File "/home/jeffrey/workspace/romulan-env/local/lib/python2.7/site-packages/openpyxl/writer/excel.py", line 81, in write_data
    self._write_worksheets()
  File "/home/jeffrey/workspace/romulan-env/local/lib/python2.7/site-packages/openpyxl/writer/excel.py", line 197, in _write_worksheets
    xml = ws._write()
  File "/home/jeffrey/workspace/romulan-env/local/lib/python2.7/site-packages/openpyxl/worksheet/worksheet.py", line 870, in _write
    return write_worksheet(self)
  File "/home/jeffrey/workspace/romulan-env/local/lib/python2.7/site-packages/openpyxl/writer/worksheet.py", line 163, in write_worksheet
    tables = _add_table_headers(ws)
  File "/home/jeffrey/workspace/romulan-env/local/lib/python2.7/site-packages/openpyxl/writer/worksheet.py", line 188, in _add_table_headers
    col.name = str(cell.value)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)

when I write some non-ascii char into excel, the error raised.

then I change col.name = str(cell.value) tocol.name = cell.value, it's ok.

Comments (3)

  1. Log in to comment