我正在尝试使用 perl 模块 Excel::Writer::XLSX 构建一个带有轮廓行的电子表格。我需要行大纲符号出现在大纲级别栏上方。当我运行下面的脚本时,轮廓符号和水平条被正确生成,但向下移动了一行。
use strict;
use Excel::Writer::XLSX;
my $visible = 1;
my $symbols_below = 0;
my $symbols_right = 0;
my $auto_style = 0;
my $output_rpt = 'report.xlsx';
my $color1 = "#CBBEA0";
my $color2 = "#DDD7C5";
my $workbook = Excel::Writer::XLSX->new( $output_rpt );
my $worksheet1 = $workbook->add_worksheet( 'report' );
$worksheet1->outline_settings($visible, $symbols_below, $symbols_right, $auto_style);
my $format1 = $workbook->add_format( bold => 1, bg_color => $color1, align => 'center' );
my $format2 = $workbook->add_format( bold => 1, bg_color => $color1, align => 'left' );
my $format3 = $workbook->add_format( bold => 1, bg_color => $color2, align =>'left' );
my $format4 = $workbook->add_format( align => 'center' );
my @last = qw( Smith Jones Panglossian );
my @first = qw( Algonquin Mephibosheth Noah );
my @age = (24, 42, 962);
my @hidden = (0, 0, 0);
my @level = (0, 1, 1);
my @collapsed = (1, 0, 0);
for my $idx (0..2) {
my $row = $idx+1;
$worksheet1->set_row( $row, undef, undef, $hidden[$idx], $level[$idx],
$collapsed[$idx] );
$worksheet1->write( 'A' . $row, $first[$idx], $format2);
$worksheet1->write( 'B' . $row, $last[$idx], $format3);
$worksheet1->write( 'C' . $row, $age[$idx], $format4);
}
$workbook->close();
输出电子表格如下图所示。请注意,大纲栏偏移 1 行