Not a Perl question per-se: This code creates an Excel file containing a column chart with one series of 36 points. The color of each column in this series is the same color.
My question is: how can one use Perl to assign the fill color '#ED7D31' to the first 12 columns, '#4472C4' to the following 12 columns, and '#00B050' to the final 12 columns?
In case it matters: perl 5.24 running on Windows 7.
#! perl -w
use strict;
use warnings;
use Excel::Writer::XLSX;
my $workbook = Excel::Writer::XLSX->new( 'test.xlsx' );
my $worksheet = $workbook->add_worksheet( 'C' );
my $a_fill_color = $workbook->add_format( bg_color => '#ED7D31' );
my $b_fill_color = $workbook->add_format( bg_color => '#4472C4' );
my $c_fill_color = $workbook->add_format( bg_color => '#00B050' );
my $headings = [ 'FY 2024 Big-3', 'Total' ];
my $data = [
[ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan', 'Feb', 'Mar', 'A
+pr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan', 'Feb', 'Mar', 'A
+pr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan', 'Feb', 'Mar', 'A
+pr', 'May', 'Jun',
],
[ 15, 18, 17, 16, 13, 12, 20, 16, 35, 10, 22, 21,
10, 22, 20, 28, 24, 28, 23, 34, 39, 27, 56, 35,
5, 7, 7, 2, 7, 5, 7, 3, 6, 12, 3, 2,
],
];
$worksheet->write( 'A1', $headings );
$worksheet->write( 'A2', $data );
my $chart = $workbook->add_chart(
type => 'column',
subtype => 'clustered',
embedded => 1,
name => 'CHART03' );
$chart->add_series(
name => '=C!$B$1',
categories => '=C!$A$2:$A$37',
values => '=C!$B$2:$B$37',
data_labels => { value => 1 },
gap => 40,
);
$chart->set_title ( name => 'FY 2024 Big-3' );
$chart->set_legend( position => 'none' );
$chart->set_style( 10 );
$chart->set_x_axis( name => '', minor_unit => 1, major_unit => 1 );
$chart->set_y_axis( name => '' );
$chart->set_size(width => 1200, height => 600);
$worksheet->insert_chart( '=C!$D$1', $chart, 10, 10 );
$workbook->close() or die "XLSX: Error closing file: $!";
exit(0);
Searched for donut and crumpit. Found donate and stumbit instead.