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