excel graphs using perl

Posted by user1822725 on Stack Overflow See other posts from Stack Overflow or by user1822725
Published on 2012-11-14T04:50:51Z Indexed on 2012/11/14 4:59 UTC
Read the original article Hit count: 225

Filed under:

i amfacing problem when i ran the script its giving error like Can't locate object method "add_chart" via package "Spreadsheet::WriteExcel" at chart_column.pl line 33. May i know what is the problem here? And i am using perl, v5.8.5 built for x86_64-linux. #!/usr/bin/perl -w

###############################################################################
#
# A simple demo of Column charts in Spreadsheet::WriteExcel.
#
# reverse('©'), December 2009, John McNamara, [email protected]
#

use strict;
use Spreadsheet::WriteExcel;

my $workbook  = Spreadsheet::WriteExcel->new( 'chart_column.xls' );
my $worksheet = $workbook->add_worksheet();
my $bold      = $workbook->add_format( bold => 1 );

# Add the worksheet data that the charts will refer to.
my $headings = [ 'Category', 'Values 1', 'Values 2' ];
my $data = [
    [ 2, 3, 4, 5, 6, 7 ],
    [ 1, 4, 5, 2, 1, 5 ],
    [ 3, 6, 7, 5, 4, 3 ],
];

$worksheet->write( 'A1', $headings, $bold );
$worksheet->write( 'A2', $data );


###############################################################################
#
# Example 1. A minimal chart.
#
my $chart1 = $workbook->add_chart( type => 'column' );

# Add values only. Use the default categories.
$chart1->add_series( values => '=Sheet1!$B$2:$B$7' );

# Insert the chart into the main worksheet.
$worksheet->insert_chart( 'E2', $chart1 );

© Stack Overflow or respective owner

Related posts about perl