mirror of
https://github.com/kennethreitz/tablib.git
synced 2026-06-05 23:10:17 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3c66697280 | |||
| 13334b7996 | |||
| 77a5c8d3fb | |||
| 79d66cd250 | |||
| 77469ef655 | |||
| e21676d3bd | |||
| 7c59e1ae86 |
@@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -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
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user