Compare commits

...

11 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
kennethreitz 2814fbc381 v0.11.3 2016-02-16 08:49:28 -05:00
kennethreitz 9ca1d4ec54 Merge pull request #220 from kennethreitz/master
Master
2016-02-16 08:46:37 -05:00
kennethreitz abbb4e32d8 update footer in docs 2016-02-16 08:29:17 -05:00
kennethreitz 9ba0451843 Merge pull request #219 from timofurrer/bugfix/export-only
Fix export only formats
2016-02-16 08:17:56 -05:00
5 changed files with 21 additions and 18 deletions
+5
View File
@@ -1,6 +1,11 @@
History History
------- -------
0.11.3 (2016-02-16)
+++++++++++++++++++
- Release fix.
0.11.2 (2016-02-16) 0.11.2 (2016-02-16)
+++++++++++++++++++ +++++++++++++++++++
+1 -1
View File
@@ -41,7 +41,7 @@ master_doc = 'index'
# General information about the project. # General information about the project.
project = u'Tablib' project = u'Tablib'
copyright = u'2011. A <a href="http://kennethreitz.com/pages/open-projects.html">Kenneth Reitz</a> Project' copyright = u'2016. A <a href="http://kennethreitz.org/">Kenneth Reitz</a> Project'
# The version info for the project you're documenting, acts as replacement for # The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the # |version| and |release|, also used in various other places throughout the
+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. 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
+3 -3
View File
@@ -18,8 +18,8 @@ from tablib.compat import OrderedDict, unicode
__title__ = 'tablib' __title__ = 'tablib'
__version__ = '0.11.2' __version__ = '0.11.3'
__build__ = 0x001102 __build__ = 0x001103
__author__ = 'Kenneth Reitz' __author__ = 'Kenneth Reitz'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright 2016 Kenneth Reitz' __copyright__ = 'Copyright 2016 Kenneth Reitz'
@@ -1105,7 +1105,7 @@ class Databook(object):
"""The number of the :class:`Dataset` objects within :class:`Databook`.""" """The number of the :class:`Dataset` objects within :class:`Databook`."""
return len(self._datasets) 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`. Import `in_stream` to the :class:`Databook` object using the `format`.
+11 -13
View File
@@ -17,6 +17,7 @@ import tablib
Workbook = openpyxl.workbook.Workbook Workbook = openpyxl.workbook.Workbook
ExcelWriter = openpyxl.writer.excel.ExcelWriter ExcelWriter = openpyxl.writer.excel.ExcelWriter
get_column_letter = openpyxl.cell.get_column_letter get_column_letter = openpyxl.cell.get_column_letter
DataTypeException = openpyxl.shared.exc.DataTypeException
from tablib.compat import unicode from tablib.compat import unicode
@@ -120,33 +121,30 @@ def dset_sheet(dataset, ws, freeze_panes=True):
if (row_number == 1) and dataset.headers: if (row_number == 1) and dataset.headers:
# ws.cell('%s%s'%(col_idx, row_number)).value = unicode( # ws.cell('%s%s'%(col_idx, row_number)).value = unicode(
# '%s' % col, errors='ignore') # '%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 = ws.get_style('%s%s' % (col_idx, row_number))
style.font.bold = True style.font.bold = True
if freeze_panes: if freeze_panes:
# As already done in #53, but after Merge lost: # As already done in #53, but after Merge lost:
# Export Freeze only after first Line # Export Freeze only after first Line
ws.freeze_panes = 'A2' ws.freeze_panes = 'A2'
# bold separators # bold separators
elif len(row) < dataset.width: 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 = ws.get_style('%s%s' % (col_idx, row_number))
style.font.bold = True style.font.bold = True
# wrap the rest # wrap the rest
else: else:
try: try:
if '\n' in col: str_col_value = unicode(col)
ws.cell('%s%s'%(col_idx, row_number)).value = unicode( except TypeError:
'%s' % col, errors='ignore') str_col_value = ''
if '\n' in str_col_value:
style = ws.get_style('%s%s' % (col_idx, row_number)) style = ws.get_style('%s%s' % (col_idx, row_number))
style.alignment.wrap_text 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)