OpenOffice-OODoc - Re: how spanCell can be used for vertical spanning

Posted on Wed Jun 14 01:01:23 2006 by jmgdoc in response to 2474 (See the whole thread of 3)
Re: how spanCell can be used for vertical spanning

Vertical spanning is not currently provided by cellSpan().
But it can be done using the low-level XML API.
First, the "covering" (expanded) cell must be provided with a 'number-rows-spanned' attribute, and this attribute must be set according to the desired span.
Second, each XML tag corresponding to a covered cell must be changed from 'table-cell' to 'table-covered-cell'. Changing the tag of an element can be done through the set_name method (set_name is an element method, not a document method; it's provided by XML::Twig, so it's not documented in O::O).

The very simple example below provides the "B2" cell of a given sheet with a 2-row vertical span (so it creates the 'number-rows-spanned' attribute in "B2" and turns "B3" (the cell below) to a covered cell. Of course, all this stuff works in the declared area of a previously "normalized" table.
my $table = $doc->getTable("Sheet1", 10, 10); my $expanded_cell = $doc->getCell($table, "B2"); $doc->setAttribute ( $expanded_cell, 'table:number-rows-spanned' => 2 ); $doc->getCell($table, "B3")->set_name('table:covered-table-cell');

This example could be easily extended to a bi-directionnal cell span, where "B2" could cover "B3", "C2", and "C3", using both 'number-rows-spanned' and 'number-columns-spanned':
my $table = $doc->getTable("Sheet1", 10, 10); my $expanded_cell = $doc->getCell($table, "B2"); $doc->setAttribute ( $expanded_cell, 'table:number-rows-spanned' => 2, 'table:number-columns-spanned' => 2 ); $doc->getCell($table, "B3")->set_name('table:covered-table-cell'); $doc->getCell($table, "C2")->set_name('table:covered-table-cell'); $doc->getCell($table, "C3")->set_name('table:covered-table-cell');
Direct Responses: 2512 | Write a response