Krishnakant <hackin...@gmail.com> writes: > However when I apply the same elements and attributes to the one I am > creating with odfpy, I get "attribute not allowed " errors. > If some one is interested to look at the code, please let me know, I can > send an attachment off the list so that others are not forced to > download some thing they are not concerned about.
I just tried this myself and the following creates a 3x3 spreadsheet with the first row spanning all three columns (no special formatting like centering or anything), using odf2py 0.8: import sys from odf.opendocument import OpenDocumentSpreadsheet from odf.style import Style, TableColumnProperties from odf.table import Table, TableRow, TableColumn, \ TableCell, CoveredTableCell from odf.text import P def make_ods(): ods = OpenDocumentSpreadsheet() col = Style(name='col', family='table-column') col.addElement(TableColumnProperties(columnwidth='1in')) table = Table() table.addElement(TableColumn(numbercolumnsrepeated=3, stylename=col)) ods.spreadsheet.addElement(table) # Add first row with cell spanning columns A-C tr = TableRow() table.addElement(tr) tc = TableCell(numbercolumnsspanned=3) tc.addElement(P(text="ABC1")) tr.addElement(tc) # Uncomment this to more accurately match native file ##tc = CoveredTableCell(numbercolumnsrepeated=2) ##tr.addElement(tc) # Add two more rows with non-spanning cells for r in (2,3): tr = TableRow() table.addElement(tr) for c in ('A','B','C'): tc = TableCell() tc.addElement(P(text='%s%d' % (c, r))) tr.addElement(tc) ods.save("ods-test.ods") Maybe that will give you a hint as to what is happening in your case. Note that it appears creating such a spreadsheet directly in Calc also adds covered table cells for those cells beneath the spanned cell, but Calc loads a file fine without those and still lets you later split the merge and edit the underlying cells. So I'm not sure how required that is as opposed to just how Calc manages its own internal structure. -- David -- http://mail.python.org/mailman/listinfo/python-list