summaryrefslogtreecommitdiff
path: root/tablib
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2019-10-03 23:44:24 +0200
committerClaude Paroz <claude@2xlibre.net>2019-10-04 19:45:42 +0200
commit5fde5259d9adcfc47db93110d2dac6b08f31e24f (patch)
tree6bae1e205c966871e54586b22f19857b49064644 /tablib
parent591e8f74489bcd2b60e1dd39154f3078adbec827 (diff)
downloadtablib-5fde5259d9adcfc47db93110d2dac6b08f31e24f.tar.gz
Fixes #314 - Delegate type coercion to openpyxl
Thanks Cristiano Lopes for the initial patch.
Diffstat (limited to 'tablib')
-rw-r--r--tablib/formats/_xlsx.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/tablib/formats/_xlsx.py b/tablib/formats/_xlsx.py
index a2d46ce..6662a2f 100644
--- a/tablib/formats/_xlsx.py
+++ b/tablib/formats/_xlsx.py
@@ -117,8 +117,6 @@ def dset_sheet(dataset, ws, freeze_panes=True):
# bold headers
if (row_number == 1) and dataset.headers:
- # cell.value = unicode('%s' % col, errors='ignore')
- cell.value = unicode(col)
cell.font = bold
if freeze_panes:
# Export Freeze only after first Line
@@ -126,16 +124,18 @@ def dset_sheet(dataset, ws, freeze_panes=True):
# bold separators
elif len(row) < dataset.width:
- cell.value = unicode('%s' % col, errors='ignore')
cell.font = bold
# wrap the rest
else:
try:
- if '\n' in col:
- cell.value = unicode('%s' % col, errors='ignore')
- cell.alignment = wrap_text
- else:
- cell.value = unicode('%s' % col, errors='ignore')
+ str_col_value = unicode(col)
except TypeError:
- cell.value = unicode(col)
+ str_col_value = ''
+ if '\n' in str_col_value:
+ cell.alignment = wrap_text
+
+ try:
+ cell.value = col
+ except (ValueError, TypeError):
+ cell.value = unicode(col)