Posted on 2009-04-12 07:02:36-07 by smc in response to 6371
Re: Cell style definition
This is a cell style example.

1) load any fonts you want to use
$styles->importFontDeclaration ( '<style:font-face style:name="Calibri" svg:font-family="Calibri" s +tyle:font-adornments="Regular" style:font-pitch="variable"/>');
2) define style in styles.xml. Note the use of table-cell
$styles->createStyle ( 'DataHeading', family => 'table-cell', parent => 'Default', properties => { -area => 'table-cell', 'display-name' => 'DataHeading', 'fo:background-color' => '#000080', 'fo:border' => "0.002cm solid #000000", 'vertical-align' => "middle", } ); if ($doc->isOpenDocument) { $styles->styleProperties ('DataHeading', -area => 'text', 'fo:color' => odfColor("white"), 'style:font-name' => 'Calibri', 'fo:font-size' => '12pt', 'fo:font-weight' => 'bold' ); $styles->styleProperties ('DataHeading', -area => 'paragraph', 'fo:text-align' => 'center' # start (left), center, end (right) ); }
This code will set a spreadsheet table column width:
1) Create style in main document (context.xml, not styles.xml)
$doc->createStyle ( 'ColW2', family => 'table-column', properties => { -area => 'table-column', 'fo:break-before' => 'auto', 'column-width' => '2cm' } );
2) apply
# Set column widths, columns are numbered beginning at 0. $doc->columnStyle($sheet, 0, 'ColW2');

I am far from an opendoc expert, but after lots of trial and error and some tips from the documentation, I did get these snippets working in a spreadsheet.
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.