see OpenOffice::OODoc::Styles in particular the section
building styles from scratch by program is not a recommended practice. It's much more easy to create documents which all the needed styles through an ODF-compliant office software, and to use them as templates in the programs, knowing that it's very easy to retrieve an existing style, to copy it and to re-use it (as is or customised) in new documents.

However, for your relatively simple requirements try this

#!/usr/bin/perl use strict; use OpenOffice::OODoc; my $doc = odfDocument(file => 'test.odt', create => 'text'); $doc->createStyle( "border", family => 'table-cell', parent => 'Standard', properties => { 'fo:border' => "0.05cm solid #000000", 'fo:padding' => "0.05cm", } ); $doc->createStyle( "2cm", family => 'table-column', parent => 'Standard', properties => { 'style:column-width' => "2cm" } ); $doc->createStyle( "6cm", family => 'table-column', parent => 'Standard', properties => { 'style:column-width' => "6cm" } ); $doc->createStyle( "theading", family => 'paragraph', parent => 'Standard', properties => { -area => 'text', 'fo:font-size' => '13pt', 'fo:font-weight' => 'bold', 'fo:color' => '#000000', # black 'fo:font-family' => 'arial', } ); $doc->updateStyle( "theading", properties => { 'fo:background-color' => "#c0c0c0" , # light grey } ); my @width = ('2cm','6cm','2cm'); my @data = ( ['S No','Name','Value'], ['A1','B1','C1'], ['A2','B2','C2'], ['A3','B3','C3'], ['A4','B4','C4'] ); my $table = $doc->appendTable('tab1',5,3); for my $c (0..2){ $doc->columnStyle('tab1',$c,$width[$c]); for my $r (0..4){ $doc->cellStyle('tab1',$r,$c,'border'); $doc->cellValue('tab1',$r,$c,$data[$r][$c]); } $doc->setAttributes($doc->getCellParagraph("tab1",0,$c),'text:style- +name' => 'theading'); } $doc->save;
poj

In reply to Re: working with tables in OpenOffice::OODoc by poj
in thread working with tables in OpenOffice::OODoc by swathibandaru

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.