Skip to content

grammar is outdated #143

Description

@Andrej730

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)

Patching grammar this way also helps:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions