Merge current-dev 0.30 back to trunk
[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
8fd01531 12sub exit_scope { $_[1]->active_worksheet( undef ) }
13
d0eafc11 14sub render
15{
16 my $self = shift;
17 my ($context) = @_;
18
8fd01531 19 my $worksheet = $context->new_worksheet( $self );
d0eafc11 20
dba6a68e 21 my $password = $context->get( $self, 'PROTECT' );
22 if (defined $password)
23 {
8fd01531 24 $worksheet->protect( $password );
dba6a68e 25 }
26
8fd01531 27 $worksheet->keep_leading_zeros( 1 )
28 if $context->mark( 'keep_leading_zeros' );
d01e4722 29
82112547 30 if ( $context->get( $self, 'LANDSCAPE' ) && !$self->{PORTRAIT} ) {
31 $worksheet->set_landscape;
32 }
33 elsif ( $context->get( $self, 'PORTRAIT' ) ) {
34 $worksheet->set_portrait;
35 }
36
d0eafc11 37 return $self->SUPER::render($context);
38}
39
401;
41__END__
42
43=head1 NAME
44
45Excel::Template::Container::Worksheet - Excel::Template::Container::Worksheet
46
47=head1 PURPOSE
48
49To provide a new worksheet.
50
51=head1 NODE NAME
52
53WORKSHEET
54
55=head1 INHERITANCE
56
57Excel::Template::Container
58
59=head1 ATTRIBUTES
60
61=over 4
62
63=item * NAME
64
65This is the name of the worksheet to be added.
66
dba6a68e 67=item * PROTECT
68
69If the attribute exists, it will mark the worksheet as being protected. Whatever
70value is set will be used as the password.
71
72This activates the HIDDEN and LOCKED nodes.
73
d01e4722 74=item * KEEP_LEADING_ZEROS
75
76This will change the behavior of the worksheet to preserve leading zeros.
77
82112547 78=item * LANDSCAPE
79
80This will set the worksheet's orientation to landscape.
81
82=item * PORTRAIT
83
84This will set the worksheet's orientation to portrait.
85
86While this is the default, it's useful to override the default at times. For
87example, in the following situation:
88
89 <workbook landscape="1">
90 <worksheet>
91 ...
92 </worksheet
93 <worksheet portrait="1">
94 ...
95 </worksheet
96 <worksheet>
97 ...
98 </worksheet
99 </workbook>
100
101In that example, the first and third worksheets will be landscape (inheriting
102it from the workbook node), but the second worksheet will be portrait.
103
6dd4c89d 104=back
d0eafc11 105
106=head1 CHILDREN
107
108None
109
110=head1 EFFECTS
111
112None
113
114=head1 DEPENDENCIES
115
116None
117
118=head1 USAGE
119
120 <worksheet name="My Taxes">
121 ... Children here
122 </worksheet>
123
124In the above example, the children will be executed in the context of the
125"My Taxes" worksheet.
126
127=head1 AUTHOR
128
c09684ff 129Rob Kinyon (rob.kinyon@gmail.com)
d0eafc11 130
131=head1 SEE ALSO
132
133ROW, CELL, FORMULA
134
135=cut