Thread

Posted on Tue Oct 2 23:21:54 2007 by namotco8
trouble with column width
I saw the previous post about column width. I've tried that, but I'm still getting the default. I'm able to set cell styles, but not column or other table attributes. Here are some things I've tried:
my $c1Style = $document->columnStyle($rectable, 0); $document->updateStyle($c1Style, properties => { area => 'table-column', 'style:column-width' => '1cm', 'style:use-optimal-column-width' => 'false' });
Also:
$document->createStyle("Narrow", family=>'table-column', parent=> "Default", properties=>{ area => 'table-column', 'style:column-width' => '1cm' } ); my $colom=$document->getColumn($rectable, 0); $document->columnStyle($colom,'Narrow');
What I'm doing is:
my $rectable = $document->insertTable ( $recommendationSect, $tname , @{$href->{$opts}->{$val}} +1 , 3, 'table-style' => 'borders1pt', #'cell-type' => default cell type 'cell-style' => 'noBordersCell', 'text-style' => 'P1' ); $document->moveElementsToSection('recommendations', $rectable); # ... then I add some values and cell styling like so: $document->cellValue($tname, $rrcnt,0, " -".uc($rec->{andor})."- " ) unless ($hr || $rec->{medCa +tegory} eq 'Discontinue'); $document->cellStyle($tname, $rrcnt, 1, 'currentMedTableRowCell') if $hr; # add some space at the end of the table next: my $p = $document->insertParagraph($rectable, "\n", 'position' => 'after'); $document->setText($p, "\n\n"); # Next I try some table styles which don't seem to work (I check in the XML...) $document->updateStyle($tstyle, properties => { 'fo:border-top' => "0.00695 solid #000000", 'fo:border-bottom' => "0.00695 solid #000000", 'fo:border-left' => "none", 'fo:border-right' => "none", 'fo:background-color' => "#007BC2", 'width' => "6.5in", 'style:may-break-between-rows' => "false" }); # and then column widths which also don't work: my $c1Style = $document->columnStyle($rectable, 0); $document->updateStyle($c1Style, properties => { area => 'table-column', 'style:column-width' => '1cm', 'style:use-optimal-column-width' => 'false' }); my $c2Style = $document->columnStyle($rectable, 1); $document->updateStyle($c2Style, properties => { 'style:rel-column-width' => "5815*", area => 'table-column', 'style:column-width' => '4.0382in', 'style:use-optimal-column-width' => 'false' }); my $c3Style = $document->columnStyle($rectable, 2); $document->updateStyle($c3Style, properties => { 'style:rel-column-width' => "3324*", area => 'table-column', 'style:column-width' => '2.3083in', 'style:use-optimal-column-width' => 'false' });
I don't understand where I've gone wront...
Direct Responses: 6984 | Write a response
Posted on Thu Jan 31 23:27:46 2008 by keithjr in response to 6158
Re: trouble with column width
I was having the same trouble, but managed to get it working using a different style property. Try replacing column-width with rel-column-width, like so:
$doc->createStyle("ColS", family=>'table-column', parent=> "Default", properties=> { area => 'table-column', 'style:rel-column-width' => "100*" }); $doc->createStyle("ColM", family=>'table-column', parent=> "Default", properties=> { area => 'table-column', 'style:rel-column-width' => "200*" }); $doc->createStyle("ColL", family=>'table-column', parent=> "Default", properties=> { area => 'table-column', 'style:rel-column-width' => "300*" }); my $col; $col = $doc->getColumn($table,0); $doc->columnStyle($col,'ColS'); $col = $doc->getColumn($table,1); $doc->columnStyle($col,'ColM'); $col = $doc->getColumn($table,2); $doc->columnStyle($col,'ColL');
Basically, the width of each column is the column's rel-column-width number divided by the total sum of all rel-column-width markers in the table. So, the third column would be 1/2 the table width, for example. Also, each number needs an asterisk trailing it (ODF requirement). I couldn't get the fixed widths to work at all, even though they seemed to be correct in the generated XML.
Write a response