Commit | Line | Data |
d0eafc11 |
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 | |
8fd01531 |
12 | sub exit_scope { $_[1]->active_worksheet( undef ) } |
13 | |
d0eafc11 |
14 | sub 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 | |
40 | 1; |
41 | __END__ |
42 | |
43 | =head1 NAME |
44 | |
45 | Excel::Template::Container::Worksheet - Excel::Template::Container::Worksheet |
46 | |
47 | =head1 PURPOSE |
48 | |
49 | To provide a new worksheet. |
50 | |
51 | =head1 NODE NAME |
52 | |
53 | WORKSHEET |
54 | |
55 | =head1 INHERITANCE |
56 | |
57 | Excel::Template::Container |
58 | |
59 | =head1 ATTRIBUTES |
60 | |
61 | =over 4 |
62 | |
63 | =item * NAME |
64 | |
65 | This is the name of the worksheet to be added. |
66 | |
dba6a68e |
67 | =item * PROTECT |
68 | |
69 | If the attribute exists, it will mark the worksheet as being protected. Whatever |
70 | value is set will be used as the password. |
71 | |
72 | This activates the HIDDEN and LOCKED nodes. |
73 | |
d01e4722 |
74 | =item * KEEP_LEADING_ZEROS |
75 | |
76 | This will change the behavior of the worksheet to preserve leading zeros. |
77 | |
82112547 |
78 | =item * LANDSCAPE |
79 | |
80 | This will set the worksheet's orientation to landscape. |
81 | |
82 | =item * PORTRAIT |
83 | |
84 | This will set the worksheet's orientation to portrait. |
85 | |
86 | While this is the default, it's useful to override the default at times. For |
87 | example, 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 | |
101 | In that example, the first and third worksheets will be landscape (inheriting |
102 | it from the workbook node), but the second worksheet will be portrait. |
103 | |
6dd4c89d |
104 | =back |
d0eafc11 |
105 | |
106 | =head1 CHILDREN |
107 | |
108 | None |
109 | |
110 | =head1 EFFECTS |
111 | |
112 | None |
113 | |
114 | =head1 DEPENDENCIES |
115 | |
116 | None |
117 | |
118 | =head1 USAGE |
119 | |
120 | <worksheet name="My Taxes"> |
121 | ... Children here |
122 | </worksheet> |
123 | |
124 | In the above example, the children will be executed in the context of the |
125 | "My Taxes" worksheet. |
126 | |
127 | =head1 AUTHOR |
128 | |
c09684ff |
129 | Rob Kinyon (rob.kinyon@gmail.com) |
d0eafc11 |
130 | |
131 | =head1 SEE ALSO |
132 | |
133 | ROW, CELL, FORMULA |
134 | |
135 | =cut |