Thread

Posted on Mon Oct 30 12:53:17 2006 by nrodriguez
Row height
Hello. I've tried to set a specific height to a row, but it hasn't been able to do it. I've read the only way to do it is by setting a style. I've created a style like this:
$styles->createStyle ( "DataRowHeight", family => 'table-row', properties => { 'style:min-row-height' => '2cm', 'style:row-height' => '2cm' #'fo:use-optimal-row-height' => 'true' } );
And then apply the style:
$document->{styles}->rowStyle($table, 0, 'DataRowHeight');
which should be set the first row of the table "$table" to 2cm. What am I doing wrong? If I set a style in a openoffice document, and take the style with the same function rowStyle, i properly get it. But it only runs for formatting style (font, color, borders...). It cannot specify the heihgt of a row in the style. Does anyone have any idea? Thank you
Direct Responses: 3389 | 3437 | Write a response
Posted on Tue Oct 31 12:17:06 2006 by jmgdoc in response to 3366
Re: Row height
Could you explain what are the $styles and
$document->{styles}
objects in your script ?

Note: the rowStyle() method should make sense in the "content" member, as long as it applies to a table in the document body. The "styles" member is the appropriate space to define a named style, but no to link a content object to a style.
Direct Responses: 3390 | Write a response
Posted on Tue Oct 31 12:38:30 2006 by nrodriguez in response to 3389
Re: Row height
Thanks for your answer. When i say
$styles
or
$document->{styles}

i make reference to objects of style member.

As you suggested, i tried to apply the style for the row height with the content member, but it either doesn't work. The only way i found to do it is setting a big character size for a cell in the row i want to resize. I don't like this solution, but it's the only way than works now.

Thank you very much
Write a response
Posted on Tue Nov 7 15:25:17 2006 by jmgdoc in response to 3366
Re: Row height
The way to control the row height needs a different approach.
Knowing that a row probably uses an existing automatic style (attributed by the spreadsheet editor), and that this style is possibly shared whith one or more other rows, we have to execute the following operations:

1) Normalize the table (according to the appropriate size) in order to ensure that the target row is not a repeated row;
2) Get the existing style of the target row, using rowStyle();
3) Create a new row style using the old one as a prototype, changing the style:row-height and style:use-optimal-row-height attributes only; caution, as long as it's an automatic style, it's hosted in the document content, not in the "styles" member; 3) Replace the old style by the new one using rowStyle() again.

That's all. As an example, the following code works for me; please tell us if it works for you...
my $content = ooDocument(file => "foo.ods", member => "content"); my $table = $content->getTable("Sheet1", 50, 50); my $row = $content->getRow($table, 0); my $old_style = $content->rowStyle($row); $content->createStyle ( "new_unique_style_name", prototype => $old_style, properties => { "style:row-height" => "2cm", "style:use-optimal-row-height" => "false" } ); $content->rowStyle($row, "new_unique_style_name"); $content->save;
Write a response