Bolding still doesn't work :(

This commit is contained in:
Mark Rogers
2011-05-15 09:00:47 -05:00
parent cb4c67767a
commit eed6df45e0
2 changed files with 12 additions and 9 deletions
+3 -3
View File
@@ -403,14 +403,14 @@ class Dataset(object):
@property
def ods():
"""An Excel Spreadsheet representation of the :class:`Dataset` object, with :ref:`separators`. Cannot be set.
"""An OpenDocument Spreadsheet representation of the :class:`Dataset` object, with :ref:`separators`. Cannot be set.
.. admonition:: Binary Warning
:class:`Dataset.xlsx` contains binary data, so make sure to write in binary mode::
with open('output.xlsx', 'wb') as f:
f.write(data.xlsx)'
with open('output.ods', 'wb') as f:
f.write(data.ods)'
"""
pass
+9 -6
View File
@@ -16,14 +16,17 @@ from tablib.compat import opendocument, style, table, text, unicode
title = 'ods'
extentions = ('ods',)
bold = style.Style(name='Bold', family="text")
bold = style.Style(name="bold", family="paragraph")
bold.addElement(style.TextProperties(fontweight="bold"))
#bold = style.Style(name='Bold', family="text")
#bold.addElement(style.TextProperties(attributes={'fontweight':"bold"}))
def export_set(dataset):
"""Returns ODF representation of Dataset."""
wb = opendocument.OpenDocumentSpreadsheet()
wb.automaticstyles.addElement(bold)
wb.styles.addElement(bold)
ws = table.Table(name=dataset.title if dataset.title else 'Tablib Dataset')
wb.spreadsheet.addElement(ws)
@@ -38,7 +41,7 @@ def export_book(databook):
"""Returns ODF representation of DataBook."""
wb = opendocument.OpenDocumentSpreadsheet()
wb.automaticstyles.addElement(bold)
wb.styles.addElement(bold)
for i, dset in enumerate(databook._datasets):
ws = table.Table(name=dset.title if dset.title else 'Sheet%s' % (i))
@@ -47,7 +50,7 @@ def export_book(databook):
stream = BytesIO()
wb.save(unicode(stream))
wb.save(stream)
return stream.getvalue()
@@ -61,7 +64,7 @@ def dset_sheet(dataset, ws):
for i, row in enumerate(_package):
row_number = i + 1
odf_row = table.TableRow(stylename=bold)
odf_row = table.TableRow(stylename=bold, defaultcellstylename='bold')
for j, col in enumerate(row):
try:
col = unicode(col, errors='ignore')
@@ -75,7 +78,7 @@ def dset_sheet(dataset, ws):
odf_row.setAttribute('stylename', bold)
ws.addElement(odf_row)
cell = table.TableCell()
cell.addElement(text.P(stylename="Bold", text=col))
cell.addElement(text.P(stylename=bold, text=col))
odf_row.addElement(cell)
# bold separators