1#!/usr/local/bin/perl -w
2
3###############################################################################
4#
5# Example of how to use the Spreadsheet::WriteExcel merge_cells() workbook
6# method with complex formatting and rotation.
7#
8#
9# reverse('�'), September 2002, John McNamara, jmcnamara@cpan.org
10#
11
12use strict;
13use Spreadsheet::WriteExcel;
14
15# Create a new workbook and add a worksheet
16my $workbook  = Spreadsheet::WriteExcel->new('merge5.xls');
17my $worksheet = $workbook->add_worksheet();
18
19
20# Increase the cell size of the merged cells to highlight the formatting.
21$worksheet->set_row($_, 36)         for (3..8);
22$worksheet->set_column($_, $_ , 15) for (1,3,5);
23
24
25###############################################################################
26#
27# Rotation 1, letters run from top to bottom
28#
29my $format1 = $workbook->add_format(
30                                    border      => 6,
31                                    bold        => 1,
32                                    color       => 'red',
33                                    valign      => 'vcentre',
34                                    align       => 'centre',
35                                    rotation    => 270,
36                                  );
37
38
39$worksheet->merge_range('B4:B9', 'Rotation 270', $format1);
40
41
42###############################################################################
43#
44# Rotation 2, 90� anticlockwise
45#
46my $format2 = $workbook->add_format(
47                                    border      => 6,
48                                    bold        => 1,
49                                    color       => 'red',
50                                    valign      => 'vcentre',
51                                    align       => 'centre',
52                                    rotation    => 90,
53                                  );
54
55
56$worksheet->merge_range('D4:D9', 'Rotation 90�', $format2);
57
58
59
60###############################################################################
61#
62# Rotation 3, 90� clockwise
63#
64my $format3 = $workbook->add_format(
65                                    border      => 6,
66                                    bold        => 1,
67                                    color       => 'red',
68                                    valign      => 'vcentre',
69                                    align       => 'centre',
70                                    rotation    => -90,
71                                  );
72
73
74$worksheet->merge_range('F4:F9', 'Rotation -90�', $format3);
75
76