如何使用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
}
}
}
答案 0 :(得分:1)
请参阅style:
style(object [, style])
返回文本或图形对象的样式名称。如果是第一个 参数是一个“母版页”(参见OODoc :: Styles),它甚至返回 相关的“页面布局”。
如果第二个给出样式名称,则替换对象的样式 参数。