Excel :: Writer :: XLSX :: Chart :: Line - 问题

时间:2011-06-17 06:30:52

标签: perl excel colors charts spreadsheet

有没有办法对图表中的线条(最高温度和最低温度)之间的空间进行着色?

#!/usr/local/bin/perl
use warnings;
use 5.014;
use utf8;
use Excel::Writer::XLSX;
my $workbook = Excel::Writer::XLSX->new( 'spreadsheet.xlsx' ) or die $!;
my $worksheet = $workbook->add_worksheet( 'One' );
my $ref = [
[ 'Day', 'Max. Temp.', 'Min. Temp' ],
[ 1, -3.1, -6.4 ],
[ 2, -2.3, -7.2 ],
[ 3, -4.7, -6.8 ],
[ 4, -3.1, -9.5 ],
[ 5, 1.1, -11.4 ],
[ 6, 1.2, 0.3 ],
[ 7, 5.3, 0.7 ],
[ 8, 7.7, 1.5 ],
[ 9, 1.5, -2 ],
[ 10, 1, -1.1 ] ];
$worksheet->write_col( 0, 0, $ref );

my $chart = $workbook->add_chart( type => 'line' );
$chart->set_x_axis( name => 'Day' );
$chart->set_y_axis( name => 'Temperature (° Celsius)' );
$chart->set_style( 11 );

$chart->add_series(
    values => [ 'One', 1, $#$ref, 1, 1 ],
    name => '=One!$B$1',
);

$chart->add_series(
    values => [ 'One', 1, $#$ref, 2, 2 ],
    name => '=One!$C$1',
);

1 个答案:

答案 0 :(得分:2)

我认为此功能在Excel中不可用,因此Excel::Writer::XLSX无法使用此功能。

至少它在Excel中不能作为单个操作使用。有一些解决方法,例如herehere,但您目前在Excel :: Writer :: XLSX中没有这种控制级别。

将来的版本中将添加Droplines / High-Low行。这可能是一种可接受的解决方法。