~ubuntu-branches/ubuntu/gutsy/horae/gutsy

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Carlo Segre
  • Date: 2006-12-28 12:36:48 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061228123648-9xnjr76wfthd92cq
Tags: 064-1
New upstream release, dropped dependency on libtk-filedialog-perl.

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 pie chart extracted from the file Chart2.xls as follows:
10
 
#
11
 
#   perl chartex.pl -c=demo2 Chart2.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("demo2.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('demo201.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, bold => 1);
34
 
$workbook->add_format(color => 2);
35
 
$workbook->add_format(color => 3);
36
 
 
37
 
 
38
 
# Add all other formats.
39
 
my $bold      = $workbook->add_format(bold => 1);
40
 
 
41
 
 
42
 
# Adjust column widths and add some headers
43
 
$worksheet->set_column('A:B', 20);
44
 
 
45
 
$worksheet->write('A1', 'Module',        $bold);
46
 
$worksheet->write('B1', 'No. of lines', $bold);
47
 
 
48
 
 
49
 
# Add data to range that the chart refers to.
50
 
my @data = (
51
 
 
52
 
            ['BIFFwriter.pm',   275],
53
 
            ['Big.pm',           99],
54
 
            ['Chart.pm',        269],
55
 
            ['Format.pm',       724],
56
 
            ['Formula.pm',     1410],
57
 
            ['OLEwriter.pm',    447],
58
 
            ['Utility.pm',      884],
59
 
            ['Workbook.pm',    1925],
60
 
            ['WorkbookBig.pm',  112],
61
 
            ['Worksheet.pm',   3945],
62
 
        );
63
 
 
64
 
$worksheet->write_col('A2', \@data);
 
 
b'\\ No newline at end of file'