Hong has asked for the wisdom of the Perl Monks concerning the following question:
I tried to run following code from http://search.cpan.org/dist/Spreadsheet-WriteExcel/lib/Spreadsheet/WriteExcel/Chart/Pie.pm page, got error message "Can't locate object method "add_chart" via package "Spreadsheet::WriteExcel" ". I checked that "add_chart" exists in Workbook.pm
use strict; use Spreadsheet::WriteExcel; my $workbook = Spreadsheet::WriteExcel->new( 'chart_pie.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' ]; my $data = [ [ 'Apple', 'Cherry', 'Pecan' ], [ 60, 30, 10 ], ]; $worksheet->write( 'A1', $headings, $bold ); $worksheet->write( 'A2', $data ); # Create a new chart object. In this case an embedded chart. my $chart = $workbook->add_chart( type => 'pie', embedded => 1 ); # Configure the series. $chart->add_series( name => 'Pie sales data', categories => '=Sheet1!$A$2:$A$4', values => '=Sheet1!$B$2:$B$4', ); # Add a title. $chart->set_title( name => 'Popular Pie Types' ); # Insert the chart into the worksheet (with an offset). $worksheet->insert_chart( 'C2', $chart, 25, 10 ); #print "chart:@chart\"; __END__
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can't locate object method "add_chart"
by kcott (Archbishop) on Jan 25, 2017 at 05:50 UTC | |
|
Re: Can't locate object method "add_chart"
by poj (Abbot) on Jan 25, 2017 at 11:27 UTC | |
|
Re: Can't locate object method "add_chart"
by Anonymous Monk on Jan 25, 2017 at 01:35 UTC | |
|
Re: Can't locate object method "add_chart"
by madtoperl (Hermit) on Jan 25, 2017 at 13:42 UTC |