Compare commits

...

7 Commits

Author SHA1 Message Date
Timo Furrer 3c66697280 Merge pull request #315 from cls1991/develop
DataBook().load function params error.
2019-03-02 12:13:11 +01:00
cls1991 13334b7996 DataBook().load function params error 2017-10-24 19:33:35 +08:00
kennethreitz 77a5c8d3fb Merge pull request #309 from cristiano2lopes/delegate-type-coercion-to-openpyxl
Delegate type coercion to openpyxl
2017-09-11 11:51:53 -04:00
Cristiano Lopes 79d66cd250 Handle raised exceptions while setting the value on the cell
Convert the value to unicode, if not enough i think the bubbling of the
exception is the best thing to do
2017-09-11 13:05:31 +01:00
Cristiano Lopes 77469ef655 Delegate type coercion to openpyxl 2017-09-11 12:47:51 +01:00
kennethreitz e21676d3bd Merge pull request #302 from kirsn/patch-2
`Nose` link corrected
2017-08-29 22:58:35 -04:00
Kiran Subbaraman 7c59e1ae86 Nose link corrected
It now points to https://github.com/nose-devs/nose
2017-08-28 13:41:10 +05:30
3 changed files with 13 additions and 15 deletions
+1 -1
View File
@@ -155,7 +155,7 @@ Once installed, we can generate our xUnit report with a single command. ::
This will generate a **nosetests.xml** file, which can then be analyzed.
.. _Nose: http://somethingaboutorange.com/mrl/projects/nose/
.. _Nose: https://github.com/nose-devs/nose
+1 -1
View File
@@ -1105,7 +1105,7 @@ class Databook(object):
"""The number of the :class:`Dataset` objects within :class:`Databook`."""
return len(self._datasets)
def load(self, format, in_stream, **kwargs):
def load(self, in_stream, format, **kwargs):
"""
Import `in_stream` to the :class:`Databook` object using the `format`.
+10 -12
View File
@@ -17,6 +17,7 @@ import tablib
Workbook = openpyxl.workbook.Workbook
ExcelWriter = openpyxl.writer.excel.ExcelWriter
get_column_letter = openpyxl.cell.get_column_letter
DataTypeException = openpyxl.shared.exc.DataTypeException
from tablib.compat import unicode
@@ -120,7 +121,6 @@ def dset_sheet(dataset, ws, freeze_panes=True):
if (row_number == 1) and dataset.headers:
# ws.cell('%s%s'%(col_idx, row_number)).value = unicode(
# '%s' % col, errors='ignore')
ws.cell('%s%s'%(col_idx, row_number)).value = unicode(col)
style = ws.get_style('%s%s' % (col_idx, row_number))
style.font.bold = True
if freeze_panes:
@@ -130,23 +130,21 @@ def dset_sheet(dataset, ws, freeze_panes=True):
# bold separators
elif len(row) < dataset.width:
ws.cell('%s%s'%(col_idx, row_number)).value = unicode(
'%s' % col, errors='ignore')
style = ws.get_style('%s%s' % (col_idx, row_number))
style.font.bold = True
# wrap the rest
else:
try:
if '\n' in col:
ws.cell('%s%s'%(col_idx, row_number)).value = unicode(
'%s' % col, errors='ignore')
str_col_value = unicode(col)
except TypeError:
str_col_value = ''
if '\n' in str_col_value:
style = ws.get_style('%s%s' % (col_idx, row_number))
style.alignment.wrap_text
else:
ws.cell('%s%s'%(col_idx, row_number)).value = unicode(
'%s' % col, errors='ignore')
except TypeError:
ws.cell('%s%s'%(col_idx, row_number)).value = unicode(col)
try:
ws.cell('%s%s' % (col_idx, row_number)).value = col
except (ValueError, TypeError, DataTypeException):
ws.cell('%s%s' % (col_idx, row_number)).value = unicode(col)