tags:

views:

108

answers:

1

How to apply a style to cell using OpenOffice::OODoc module in Perl?

I tried:

my $container = odfContainer("report1.ods", create => 'spreadsheet');

my $doc = odfDocument (
                       container => $container,
                       part      => 'content'
                      );

# Styles
my $styles = odfDocument (
                       container => $container,
                       part      => 'styles'
                      );

$styles->createStyle ('TTT',
        family       => 'cell',
        display-name => 'Table Headers',
        properties   => {
            'fo:font-weight' => 'bold',
            'fo:color'       => '#ffffff',
        }
);

{
    for (my $x = 0; $x < $X; $x++) {
        $doc->columnStyle ($sheet, $x, "TTT"); # does not work
        for (my $y = 0; $y < $Y; $y++) {
            my $cell = $doc->getTableCell ($sheet, $y, $x);
            $doc->cellValueType ($cell, $headers->[$x][1]);
            $doc->updateCell ($cell, $data->[$y][$x]);
            $doc->setStyle ($cell, 'TTT'); # does not work
            $doc->cellStyle ($cell, 'TTT'); # does not work
        }
    }
}
+1  A: 

See style:

style(object [, style])

Returns the style name of a text or graphics object. If the first argument is a "master page" (see OODoc::Styles), it even returns the associated "page layout".

Replaces the object's style if a style name is given as the second argument.

Sinan Ünür
When I try `$doc->style ($cell, 'TTT');` I get "[OpenOffice::OODoc::Document::style] Missing object" warning message.
el.pescado
Ok, It works. `cellStyle` works too. There was problem with `createStyle` method.
el.pescado