~ubuntu-branches/ubuntu/vivid/horae/vivid

« back to all changes in this revision

Viewing changes to 0CPAN/Spreadsheet-WriteExcel-2.15/charts/demo1.pl

  • Committer: Bazaar Package Importer
  • Author(s): Carlo Segre
  • Date: 2006-12-26 11:54:29 UTC
  • Revision ID: james.westby@ubuntu.com-20061226115429-kjuhf6h9w6bohlwj
Tags: upstream-063
Import upstream version 063

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -w
 
2
 
 
3
###############################################################################
 
4
#
 
5
# Simple example of how to add an externally created chart to a Spreadsheet::
 
6
# WriteExcel file.
 
7
#
 
8
#
 
9
# This example adds a line chart extracted from the file Chart1.xls as follows:
 
10
#
 
11
#   perl chartex.pl -c=demo1 Chart1.xls
 
12
#
 
13
#
 
14
# reverse('�'), September 2004, John McNamara, jmcnamara@cpan.org
 
15
#
 
16
 
 
17
use strict;
 
18
use Spreadsheet::WriteExcel;
 
19
 
 
20
my $workbook  = Spreadsheet::WriteExcel->new("demo1.xls");
 
21
my $worksheet = $workbook->add_worksheet();
 
22
 
 
23
 
 
24
# Add the chart extracted using the chartex utility
 
25
my $chart     = $workbook->add_chart_ext('demo101.bin', 'Chart1');
 
26
 
 
27
 
 
28
# Link the chart to the worksheet data using a dummy formula.
 
29
$worksheet->store_formula('=Sheet1!A1');
 
30
 
 
31
 
 
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);
 
36
 
 
37
# Add all other formats (if any).
 
38
 
 
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);
 
42
 
 
43
$worksheet->write_col('A1', \@nums   );
 
44
$worksheet->write_col('B1', \@squares);
 
45