John said:
It doesn't appear to be quite so simple.
ODS uses a <table:table-cell> element as usual for the upper left
cell. Attributes set the range e.g. table:number-columns-spanned="3"
table:number-rows-spanned="2"
The gotcha is that it uses a *different* element for the cells covered
by the range. Example:
<table:covered-table-cell table:number-columns-repeated="2" />
This is looks like structural amendments are needed to a package like
(python-)?ooolib(-python)? that doesn't grok merged cells -- its
source doesn't contain the string "covered". Doesn't seem like it
could be done just by poking in attributes.
I guess it makes some sense that a cell that gets covered should be
changed to a covered-cell rather than merely being marked as 'covered'
or the covering left implicit by position. This would make it easier
for display software.
In any case, api-for-odfpy.odt has
5.17.12 table.CoveredTableCell
Requires the following attributes: No attribute is required.
Allows the following attributes: booleanvalue, contentvalidationname,
currency, datevalue, formula, numbercolumnsrepeated, protect,
stringvalue, stylename, timevalue, value, valuetype.
These elements contain table.CoveredTableCell: table.TableRow.
The following elements occur in table.CoveredTableCell: dr3d.Scene,
draw.A, draw.Caption, ...
so odfpy, at least, can create such elements.
Here's an example of 2 merged ranges: A1:C2 contains the text "foo"
and D1
2 contains "bar"
<table:table-row table:style-name="ro1">
- <table:table-cell table:style-name="ce1" office:value-type="string"
table:number-columns-spanned="3" table:number-rows-spanned="2">
<text
>foo</text
>
</table:table-cell>
<table:covered-table-cell table:number-columns-repeated="2" />
- <table:table-cell table:style-name="ce1" office:value-type="string"
table:number-columns-spanned="1" table:number-rows-spanned="2">
<text
>bar</text
>
</table:table-cell>
</table:table-row>
- <table:table-row table:style-name="ro1">
<table:covered-table-cell table:number-columns-repeated="4" />
</table:table-row>
Aside: If you are wondering where the cell addresses (D1 etc) are,
they're in the reader's current_row and current_col variables
Perhaps this was intended to save space, but what of table:number-
columns-repeated="4" ??
Those are the 4 cell covered in the second row -- 3 by 'foo' and 1 by
'bar'. I believe there could have been two separate entries, but this
is more compact, if less clear ;-)
Terry Jan Reedy