Skip to content

Commit

Permalink
Unicode fix in get_col_xml_string
Browse files Browse the repository at this point in the history
  • Loading branch information
kz26 committed Jul 28, 2016
1 parent 9392592 commit be8a167
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
0.6.8
* Add requirement for six >= 1.4.0
0.7.0 (July 28, 2016)
* Close file handle when saving workbook (PR #49)
* Add show\_grid\_lines from PR #47 (thanks @aarimond)
* Fix issue #44 (thanks @acGitUser and @hanstzalora)
* Styles bugfixes - merge PR #46 (thanks @bazzisoft)
* Various minor bugfixes and code cleanup

0.6.7
* Add requirement for six >= 1.4.0
* Fix UnicodeDecodeError with unicode cell content (#35) and add unicode test case

0.6.6
Expand Down
7 changes: 6 additions & 1 deletion pyexcelerate/Worksheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,12 @@ def get_col_xml_string(self, col):
size = 0
for x, row in self._cells.items():
if col in row:
size = max((len(str(row[col])) * 7 + 5) / 7, size)
v = row[col]
if isinstance(v, six.string_types):
v = to_unicode(v)
else:
v = six.text_type(v)
size = max((len(v) * 7 + 5) / 7, size)
else:
size = style.size if style.size else 15

Expand Down
7 changes: 2 additions & 5 deletions pyexcelerate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,5 @@
from .Color import Color
from .Panes import Panes

try:
import pkg_resources
__version__ = pkg_resources.require('PyExcelerate')[0].version
except:
__version__ = 'unknown'
from .version import __version__

10 changes: 10 additions & 0 deletions pyexcelerate/tests/test_Style.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-

from ..Workbook import Workbook
from ..Color import Color
from ..Font import Font
Expand Down Expand Up @@ -143,3 +145,11 @@ def test_no_style_xml():
wb.save(filename)
wbr = openpyxl.reader.excel.load_workbook(filename=filename,use_iterators=True)
mySheet = wbr.get_sheet_by_name(sheetname)


def test_unicode_with_styles():
wb = Workbook()
ws = wb.new_sheet(u"ʇǝǝɥsǝpoɔıun")
ws[1][1].value = u'Körperschaft des öffentlichen'
ws.set_col_style(2, Style(size=0))
wb.save(get_output_path("unicode-styles.xlsx"))
1 change: 1 addition & 0 deletions pyexcelerate/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.7.0'
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/python

from setuptools import setup
from pyexcelerate.version import __version__

setup(
name="PyExcelerate",
version='0.6.8',
version=__version__,
author="Kevin Wang, Kevin Zhang",
author_email="[email protected]",
maintainer="Kevin Zhang",
Expand Down

0 comments on commit be8a167

Please sign in to comment.