3
###############################################################################
5
# Simple example of how to add an externally created chart to a Spreadsheet::
9
# This example adds a line chart extracted from the file Chart1.xls as follows:
11
# perl chartex.pl -c=demo1 Chart1.xls
14
# reverse('�'), September 2004, John McNamara, jmcnamara@cpan.org
18
use Spreadsheet::WriteExcel;
20
my $workbook = Spreadsheet::WriteExcel->new("demo1.xls");
21
my $worksheet = $workbook->add_worksheet();
24
# Add the chart extracted using the chartex utility
25
my $chart = $workbook->add_chart_ext('demo101.bin', 'Chart1');
28
# Link the chart to the worksheet data using a dummy formula.
29
$worksheet->store_formula('=Sheet1!A1');
32
# Add some extra formats to cover formats used in the charts.
33
$workbook->add_format(color => 1);
34
$workbook->add_format(color => 2);
35
$workbook->add_format(color => 3);
37
# Add all other formats (if any).
39
# Add data to range that the chart refers to.
40
my @nums = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 );
41
my @squares = (0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100);
43
$worksheet->write_col('A1', \@nums );
44
$worksheet->write_col('B1', \@squares);