- add new option to worksheet - hide_gridlines
[p5sagit/Excel-Template.git] / lib / Excel / Template / Container / Worksheet.pm
1 package Excel::Template::Container::Worksheet;
2
3 use strict;
4
5 BEGIN {
6     use vars qw(@ISA);
7     @ISA = qw(Excel::Template::Container);
8
9     use Excel::Template::Container;
10 }
11
12 sub exit_scope { $_[1]->active_worksheet(undef) }
13
14 sub render {
15     my $self = shift;
16     my ($context) = @_;
17
18     my $worksheet = $context->new_worksheet($self);
19
20     my $password = $context->get( $self, 'PROTECT' );
21     if ( defined $password ) {
22         $worksheet->protect($password);
23     }
24
25     $worksheet->keep_leading_zeros(1)
26       if $context->mark('keep_leading_zeros');
27
28     if ( $context->get( $self, 'LANDSCAPE' ) && !$self->{PORTRAIT} ) {
29         $worksheet->set_landscape;
30     } elsif ( $context->get( $self, 'PORTRAIT' ) ) {
31         $worksheet->set_portrait;
32     }
33
34    
35     my $hide_gridlines = $context->get( $self, 'HIDE_GRIDLINES');
36     
37     if ( defined $hide_gridlines ) {
38         $worksheet->hide_gridlines( $hide_gridlines );
39     }
40
41     return $self->SUPER::render($context);
42 }
43
44 1;
45 __END__
46
47 =head1 NAME
48
49 Excel::Template::Container::Worksheet - Excel::Template::Container::Worksheet
50
51 =head1 PURPOSE
52
53 To provide a new worksheet.
54
55 =head1 NODE NAME
56
57 WORKSHEET
58
59 =head1 INHERITANCE
60
61 Excel::Template::Container
62
63 =head1 ATTRIBUTES
64
65 =over 4
66
67 =item * NAME
68
69 This is the name of the worksheet to be added.
70
71 =item * PROTECT
72
73 If the attribute exists, it will mark the worksheet as being protected. Whatever
74 value is set will be used as the password.
75
76 This activates the HIDDEN and LOCKED nodes.
77
78 =item * KEEP_LEADING_ZEROS
79
80 This will change the behavior of the worksheet to preserve leading zeros.
81
82
83 =item * HIDE_GRIDLINE
84
85 his method is used to hide the gridlines on the screen and printed page. 
86 Gridlines are the lines that divide the cells on a worksheet. Screen and printed gridlines are 
87 turned on by default in an Excel worksheet. If you have defined your own cell 
88 borders you may wish to hide the default gridlines.
89
90 $worksheet->hide_gridlines();
91
92 The following values of $option are valid:
93
94     0 : Don't hide gridlines
95     1 : Hide printed gridlines only
96     2 : Hide screen and printed gridlines
97
98 If you don't supply an argument or use undef the default option is 1, i.e. only the printed gridlines are hidden.
99
100 =item * LANDSCAPE
101
102 This will set the worksheet's orientation to landscape.
103
104 =item * PORTRAIT
105
106 This will set the worksheet's orientation to portrait.
107
108 While this is the default, it's useful to override the default at times. For
109 example, in the following situation:
110
111   <workbook landscape="1">
112     <worksheet>
113       ...
114     </worksheet
115     <worksheet portrait="1">
116       ...
117     </worksheet
118     <worksheet>
119       ...
120     </worksheet
121   </workbook>
122
123 In that example, the first and third worksheets will be landscape (inheriting
124 it from the workbook node), but the second worksheet will be portrait.
125
126 =back
127
128 =head1 CHILDREN
129
130 None
131
132 =head1 EFFECTS
133
134 None
135
136 =head1 DEPENDENCIES
137
138 None
139
140 =head1 USAGE
141
142   <worksheet name="My Taxes">
143     ... Children here
144   </worksheet>
145
146 In the above example, the children will be executed in the context of the
147 "My Taxes" worksheet.
148
149 =head1 AUTHOR
150
151 Rob Kinyon (rob.kinyon@gmail.com)
152
153 =head1 SEE ALSO
154
155 ROW, CELL, FORMULA
156
157 =cut