mirror of
https://github.com/kennethreitz/tablib.git
synced 2026-06-05 15:00:19 +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.
|
||||
|
||||
.. _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`."""
|
||||
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`.
|
||||
|
||||
|
||||
+11
-13
@@ -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,33 +121,30 @@ 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:
|
||||
# As already done in #53, but after Merge lost:
|
||||
# Export Freeze only after first Line
|
||||
ws.freeze_panes = 'A2'
|
||||
|
||||
|
||||
# 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)
|
||||
|
||||
Reference in New Issue
Block a user