I created a Libre Office spreadsheet with odfpy and want some cells to have a border, but cannot figure out how to do that. I know that I can add style to a table cell and I know that TableCellProperties has an attribute called 'border'. I tried to set border=True, but that does not do anything. Can anyone please help me?
from odf.opendocument import OpenDocumentSpreadsheet
from odf.table import Table, TableRow, TableCell
from odf.style import Style, TableCellProperties
document = OpenDocumentSpreadsheet()
table = Table(name="Table1")
document.spreadsheet.addElement(table)
some_style = Style(name="some style", family="table-cell")
some_style.addElement(TableCellProperties(border=True))
document.style.addElement(some_style)
tr = TableRow()
table.addElement(tr)
cell = TableCell(stylename="some style")
tr.addElement(cell)
document.save("file.ods")
After 2 hours of searching I now found a solution:
some_style = Style(name="some style", family="table-cell")
some_style.addElement(TableCellProperties(border="0.74pt solid #808080"))
document.style.addElement(some_style)