Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grammar is outdated #143

Open
Andrej730 opened this issue Jan 14, 2025 · 0 comments
Open

grammar is outdated #143

Andrej730 opened this issue Jan 14, 2025 · 0 comments

Comments

@Andrej730
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant