1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
from lpod.document import odf_new_document
from lpod.style import odf_create_style
from lpod.table import odf_create_table
doc = odf_new_document('text')
body = doc.get_body()
cell_titre_style = odf_create_style('table-cell', area='text', weight='bold', size='13pt')
col_0_style = odf_create_style('table-column', width='3cm')
col_1_style = odf_create_style('table-column', width='7cm')
doc.insert_style(col_0_style, automatic=True)
doc.insert_style(col_1_style, automatic=True)
doc.insert_style(cell_titre_style, automatic=True)
table = odf_create_table(u"Table1", width=2, height=3)
for i in range(3):
row = table.get_row(i)
row.set_values([j + 2 for j in range(2)])
if i == 0:
for j in range(2):
c=row.get_cell(j)
c.set_style(cell_titre_style)
row.set_cell(j, c)
table.set_row(i, row)
col = table.get_column(0)
col.set_style(col_0_style)
table.set_column(0, col)
col = table.get_column(1)
col.set_style(col_1_style)
table.set_column(1, col)
body.append(table)
doc.save("lpod_test.odt") |
Partager