3
###############################################################################
5
# Simple example of how to add an externally created chart to a Spreadsheet::
9
# This example adds a pie chart extracted from the file Chart2.xls as follows:
11
# perl chartex.pl -c=demo2 Chart2.xls
14
# reverse('�'), September 2004, John McNamara, jmcnamara@cpan.org
18
use Spreadsheet::WriteExcel;
20
my $workbook = Spreadsheet::WriteExcel->new("demo2.xls");
21
my $worksheet = $workbook->add_worksheet();
24
# Add the chart extracted using the chartex utility
25
my $chart = $workbook->add_chart_ext('demo201.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, bold => 1);
34
$workbook->add_format(color => 2);
35
$workbook->add_format(color => 3);
38
# Add all other formats.
39
my $bold = $workbook->add_format(bold => 1);
42
# Adjust column widths and add some headers
43
$worksheet->set_column('A:B', 20);
45
$worksheet->write('A1', 'Module', $bold);
46
$worksheet->write('B1', 'No. of lines', $bold);
49
# Add data to range that the chart refers to.
52
['BIFFwriter.pm', 275],
57
['OLEwriter.pm', 447],
59
['Workbook.pm', 1925],
60
['WorkbookBig.pm', 112],
61
['Worksheet.pm', 3945],
64
$worksheet->write_col('A2', \@data);
b'\\ No newline at end of file'