When I use a formula to ad the name it works (first series: Max.), but when I write the name directly, I get the default name (second series: Column B instead of Min.).
Why does the second method not work here?
In Excel::Writer::XLSX::Chart#CHART_METHODS is an example which does pass the name-attribute directly.
I’m opening the file with LibreOffice.
#!/usr/local/bin/perl
use warnings;
use 5.014;
use Excel::Writer::XLSX;
my $workbook = Excel::Writer::XLSX->new( 'spreadsheet.xlsx' ) or die $!;
my $worksheet = $workbook->add_worksheet( 'One' );
my $ref = [
[ 'Max.', 'Min.' ],
[ 7, 5 ],
[ 11, 5 ],
[ 9, 2 ],
[ 8, 5 ], ];
$worksheet->write_col( 0, 0, $ref );
my $chart = $workbook->add_chart( type => 'line' );
$chart->add_series(
values => [ 'One', 1, $#$ref, 0, 0 ],
name => '=One!$A$1',
);
$chart->add_series(
values => [ 'One', 1, $#$ref, 1, 1 ],
name => 'Min.',
);
I think this is an issue with LibreOffice. The chart legend displays as expected in Excel 2007 (see below).
However, I see the same behaviour as you described in LibreOffice 3.3.3 even with files produced by Excel.