<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl

#######################################################################
#
# An example showing all 48 default chart styles available in Excel 2007
# using Excel::Writer::XLSX.. Note, these styles are not the same as the
# styles available in Excel 2013.
#
# Copyright 2000-2020, John McNamara, jmcnamara@cpan.org
#

use strict;
use warnings;
use Excel::Writer::XLSX;

my $workbook = Excel::Writer::XLSX-&gt;new( 'chart_styles.xlsx' );

# Show the styles for all of these chart types.
my @chart_types = ( 'column', 'area', 'line', 'pie' );


for my $chart_type ( @chart_types ) {

    # Add a worksheet for each chart type.
    my $worksheet = $workbook-&gt;add_worksheet( ucfirst( $chart_type ) );
    $worksheet-&gt;set_zoom( 30 );
    my $style_number = 1;

    # Create 48 charts, each with a different style.
    for ( my $row_num = 0 ; $row_num &lt; 90 ; $row_num += 15 ) {
        for ( my $col_num = 0 ; $col_num &lt; 64 ; $col_num += 8 ) {

            my $chart = $workbook-&gt;add_chart(
                type     =&gt; $chart_type,
                embedded =&gt; 1
            );

            $chart-&gt;add_series( values =&gt; '=Data!$A$1:$A$6' );
            $chart-&gt;set_title( name =&gt; 'Style ' . $style_number );
            $chart-&gt;set_legend( none =&gt; 1 );
            $chart-&gt;set_style( $style_number );

            $worksheet-&gt;insert_chart( $row_num, $col_num, $chart );
            $style_number++;
        }
    }
}

# Create a worksheet with data for the charts.
my $data = [ 10, 40, 50, 20, 10, 50 ];
my $data_worksheet = $workbook-&gt;add_worksheet( 'Data' );
$data_worksheet-&gt;write_col( 'A1', $data );
$data_worksheet-&gt;hide();

$workbook-&gt;close();

__END__
</pre></body></html>