~ubuntu-branches/ubuntu/jaunty/horae/jaunty

« back to all changes in this revision

Viewing changes to 0CPAN/Spreadsheet-WriteExcel-2.15/examples/demo.pl

  • Committer: Bazaar Package Importer
  • Author(s): Carlo Segre
  • Date: 2008-02-23 23:13:02 UTC
  • mfrom: (2.1.2 hardy)
  • Revision ID: james.westby@ubuntu.com-20080223231302-mnyyxs3icvrus4ke
Tags: 066-3
Apply patch to athena_parts/misc.pl for compatibility with 
perl-tk 804.28.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/perl -w
2
 
 
3
 
#######################################################################
4
 
#
5
 
# Demo of some of the features of Spreadsheet::WriteExcel.
6
 
# Used to create the project screenshot for Freshmeat.
7
 
#
8
 
#
9
 
# reverse('�'), October 2001, John McNamara, jmcnamara@cpan.org
10
 
#
11
 
 
12
 
use strict;
13
 
use Spreadsheet::WriteExcel;
14
 
 
15
 
my $workbook   = Spreadsheet::WriteExcel->new("demo.xls");
16
 
my $worksheet  = $workbook->add_worksheet('Demo');
17
 
my $worksheet2 = $workbook->add_worksheet('Another sheet');
18
 
my $worksheet3 = $workbook->add_worksheet('And another');
19
 
 
20
 
my $bold       = $workbook->add_format(bold => 1);
21
 
 
22
 
 
23
 
#######################################################################
24
 
#
25
 
# Write a general heading
26
 
#
27
 
$worksheet->set_column('A:A', 36, $bold);
28
 
$worksheet->set_column('B:B', 20       );
29
 
$worksheet->set_row   (0,     40       );
30
 
 
31
 
my $heading  = $workbook->add_format(
32
 
                                        bold    => 1,
33
 
                                        color   => 'blue',
34
 
                                        size    => 16,
35
 
                                        merge   => 1,
36
 
                                        align  => 'vcenter',
37
 
                                        );
38
 
 
39
 
my @headings = ('Features of Spreadsheet::WriteExcel', '');
40
 
$worksheet->write_row('A1', \@headings, $heading);
41
 
 
42
 
 
43
 
#######################################################################
44
 
#
45
 
# Some text examples
46
 
#
47
 
my $text_format  = $workbook->add_format(
48
 
                                            bold    => 1,
49
 
                                            italic  => 1,
50
 
                                            color   => 'red',
51
 
                                            size    => 18,
52
 
                                            font    =>'Lucida Calligraphy'
53
 
                                        );
54
 
 
55
 
# A phrase in Cyrillic
56
 
my $unicode = pack "H*", "042d0442043e002004440440043004370430002004".
57
 
                         "3d043000200440044304410441043a043e043c0021";
58
 
 
59
 
 
60
 
$worksheet->write('A2', "Text");
61
 
$worksheet->write('B2', "Hello Excel");
62
 
$worksheet->write('A3', "Formatted text");
63
 
$worksheet->write('B3', "Hello Excel", $text_format);
64
 
$worksheet->write('A4', "Unicode text");
65
 
$worksheet->write_unicode('B4', $unicode);
66
 
 
67
 
#######################################################################
68
 
#
69
 
# Some numeric examples
70
 
#
71
 
my $num1_format  = $workbook->add_format(num_format => '$#,##0.00');
72
 
my $num2_format  = $workbook->add_format(num_format => ' d mmmm yyy');
73
 
 
74
 
 
75
 
$worksheet->write('A5', "Numbers");
76
 
$worksheet->write('B5', 1234.56);
77
 
$worksheet->write('A6', "Formatted numbers");
78
 
$worksheet->write('B6', 1234.56, $num1_format);
79
 
$worksheet->write('A7', "Formatted numbers");
80
 
$worksheet->write('B7', 37257, $num2_format);
81
 
 
82
 
 
83
 
#######################################################################
84
 
#
85
 
# Formulae
86
 
#
87
 
$worksheet->set_selection('B8');
88
 
$worksheet->write('A8', 'Formulas and functions, "=SIN(PI()/4)"');
89
 
$worksheet->write('B8', '=SIN(PI()/4)');
90
 
 
91
 
 
92
 
#######################################################################
93
 
#
94
 
# Hyperlinks
95
 
#
96
 
$worksheet->write('A9', "Hyperlinks");
97
 
$worksheet->write('B9',  'http://www.perl.com/' );
98
 
 
99
 
 
100
 
#######################################################################
101
 
#
102
 
# Images
103
 
#
104
 
$worksheet->write('A10', "Images");
105
 
$worksheet->insert_bitmap('B10', 'republic.bmp', 16, 8);
106
 
 
107
 
 
108
 
#######################################################################
109
 
#
110
 
# Misc
111
 
#
112
 
$worksheet->write('A18', "Page/printer setup");
113
 
$worksheet->write('A19', "Multiple worksheets");
114
 
 
115