last and final attempt to search for python ods library.
John Machin
sjmachin at lexicon.net
Mon Mar 9 17:58:42 EDT 2009
On Mar 10, 6:55 am, Terry Reedy <tjre... at udel.edu> wrote:
> Krishnakant wrote:
> > I need to merge cells in a spreadsheet and this library won't do that.
>
> I think you are confusing process and result. The result is a cell that
> spans more than one column or row *when displayed*, thus hiding the
> cells that would otherwise be displayed. This is, I am 99.9% sure,
> controlled by an attribute of the visually expanded cell.
>
> In OOCalc, the process is to mark a block of cells and select Format /
> Merge Cells. But still, the result will be a change in the upper left
> attribute. Thus I suggested you make a .ods file with expanded cells
> and then read the xml to see what cell element attribute is set thereby.
> Any decent odf library will be able to set element attributes.
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.
Here's an example of 2 merged ranges: A1:C2 contains the text "foo"
and D1:D2 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:p>foo</text:p>
</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:p>bar</text:p>
</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" ??
Cheers,
John
More information about the Python-list
mailing list