如何使用 OpenOffice::OODoc 设置单元格样式?

发布于 2024-09-14 02:33:07 字数 1202 浏览 1 评论 0原文

如何使用 Perl 中的 OpenOffice::OODoc 模块将样式应用于单元格?

我试过:

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
        }
    }
}

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
        }
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ㄖ落Θ余辉 2024-09-21 02:33:07

请参阅样式 :

样式(对象[,样式])

返回文本或图形对象的样式名称。如果第一个
参数是一个“母版页”(参见 OODoc::Styles),它甚至返回
关联的“页面布局”。

如果指定了第二个样式名称,则替换对象的样式
论证。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文