diff options
| author | Cristiano Lopes <e.mail@cristianolopes.eu> | 2017-09-11 13:05:31 +0100 |
|---|---|---|
| committer | Cristiano Lopes <e.mail@cristianolopes.eu> | 2017-09-11 13:05:31 +0100 |
| commit | 79d66cd250ec4e219fb48c1a2ddc42911efeae4b (patch) | |
| tree | bc40a4b01a55c4834d39709c371017957d928dbe | |
| parent | 77469ef6556f356e93ed37e5e10b8ccccc2fbb46 (diff) | |
| download | tablib-79d66cd250ec4e219fb48c1a2ddc42911efeae4b.tar.gz | |
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
| -rw-r--r-- | tablib/formats/_xlsx.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tablib/formats/_xlsx.py b/tablib/formats/_xlsx.py index 0fb42db..c0fec0e 100644 --- a/tablib/formats/_xlsx.py +++ b/tablib/formats/_xlsx.py @@ -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 @@ -143,6 +144,7 @@ def dset_sheet(dataset, ws, freeze_panes=True): style = ws.get_style('%s%s' % (col_idx, row_number)) style.alignment.wrap_text - ws.cell('%s%s' % (col_idx, row_number)).value = 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) |
