Skip to content

Commit be8a167

Browse files
committed
Unicode fix in get_col_xml_string
1 parent 9392592 commit be8a167

File tree

6 files changed

+26
-9
lines changed

6 files changed

+26
-9
lines changed

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
0.6.8
2-
* Add requirement for six >= 1.4.0
1+
0.7.0 (July 28, 2016)
2+
* Close file handle when saving workbook (PR #49)
3+
* Add show\_grid\_lines from PR #47 (thanks @aarimond)
34
* Fix issue #44 (thanks @acGitUser and @hanstzalora)
45
* Styles bugfixes - merge PR #46 (thanks @bazzisoft)
6+
* Various minor bugfixes and code cleanup
57

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

912
0.6.6

pyexcelerate/Worksheet.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,12 @@ def get_col_xml_string(self, col):
203203
size = 0
204204
for x, row in self._cells.items():
205205
if col in row:
206-
size = max((len(str(row[col])) * 7 + 5) / 7, size)
206+
v = row[col]
207+
if isinstance(v, six.string_types):
208+
v = to_unicode(v)
209+
else:
210+
v = six.text_type(v)
211+
size = max((len(v) * 7 + 5) / 7, size)
207212
else:
208213
size = style.size if style.size else 15
209214

pyexcelerate/__init__.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,5 @@
77
from .Color import Color
88
from .Panes import Panes
99

10-
try:
11-
import pkg_resources
12-
__version__ = pkg_resources.require('PyExcelerate')[0].version
13-
except:
14-
__version__ = 'unknown'
10+
from .version import __version__
11+

pyexcelerate/tests/test_Style.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# -*- coding: utf-8 -*-
2+
13
from ..Workbook import Workbook
24
from ..Color import Color
35
from ..Font import Font
@@ -143,3 +145,11 @@ def test_no_style_xml():
143145
wb.save(filename)
144146
wbr = openpyxl.reader.excel.load_workbook(filename=filename,use_iterators=True)
145147
mySheet = wbr.get_sheet_by_name(sheetname)
148+
149+
150+
def test_unicode_with_styles():
151+
wb = Workbook()
152+
ws = wb.new_sheet(u"ʇǝǝɥsǝpoɔıun")
153+
ws[1][1].value = u'Körperschaft des öffentlichen'
154+
ws.set_col_style(2, Style(size=0))
155+
wb.save(get_output_path("unicode-styles.xlsx"))

pyexcelerate/version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = '0.7.0'

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/usr/bin/python
22

33
from setuptools import setup
4+
from pyexcelerate.version import __version__
45

56
setup(
67
name="PyExcelerate",
7-
version='0.6.8',
8+
version=__version__,
89
author="Kevin Wang, Kevin Zhang",
910
author_email="kevin+pyexcelerate@kevinzhang.me",
1011
maintainer="Kevin Zhang",

0 commit comments

Comments
 (0)