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.