-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Description
See example below - grammar doesn't have any TABLEOOONS elements leading to error setting an attribute. setAttrNS can be used as a workaround.
from odf.opendocument import OpenDocumentSpreadsheet
from odf.style import Style, TableProperties
from odf.table import Table
import odf.namespaces as odf_ns
doc = OpenDocumentSpreadsheet()
style = Style(name="bb", family="table")
style.addElement(props := TableProperties(display=True))
# AttributeError: Attribute tabcolor is not allowed in <style:table-properties>
# props.setAttribute("tabcolor", "#ff0000")
props.setAttrNS(odf_ns.TABLEOOONS, "tab-color", "#ff0000")
doc.automaticstyles.addElement(style)
table = Table(name="Tab 1")
table.setAttribute("stylename", "bb")
doc.spreadsheet.addElement(table)
output_path = r"new__.ods"
doc.save(output_path, False)Metadata
Metadata
Assignees
Labels
No labels
