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.

In reply to How to use Perl to assign different fill colors to columns in the same series of an Excel chart? by CoVAX

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.