cade8284009bba10bd64af59ed592cd0fb0a4dcb
[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 render
13 {
14     my $self = shift;
15     my ($context) = @_;
16
17     $context->new_worksheet( $self );
18
19     my $password = $context->get( $self, 'PROTECT' );
20     if (defined $password)
21     {
22         $context->active_worksheet->protect( $password );
23     }
24
25     my $keep_zeros = $context->get( $self, 'KEEP_LEADING_ZEROS' );
26     if ( defined $keep_zeros )
27     {
28         $context->active_worksheet->keep_leading_zeros( $keep_zeros ? 1 : 0 );
29     }
30
31     return $self->SUPER::render($context);
32 }
33
34 1;
35 __END__
36
37 =head1 NAME
38
39 Excel::Template::Container::Worksheet - Excel::Template::Container::Worksheet
40
41 =head1 PURPOSE
42
43 To provide a new worksheet.
44
45 =head1 NODE NAME
46
47 WORKSHEET
48
49 =head1 INHERITANCE
50
51 Excel::Template::Container
52
53 =head1 ATTRIBUTES
54
55 =over 4
56
57 =item * NAME
58
59 This is the name of the worksheet to be added.
60
61 =item * PROTECT
62
63 If the attribute exists, it will mark the worksheet as being protected. Whatever
64 value is set will be used as the password.
65
66 This activates the HIDDEN and LOCKED nodes.
67
68 =item * KEEP_LEADING_ZEROS
69
70 This will change the behavior of the worksheet to preserve leading zeros.
71
72 =back
73
74 =head1 CHILDREN
75
76 None
77
78 =head1 EFFECTS
79
80 None
81
82 =head1 DEPENDENCIES
83
84 None
85
86 =head1 USAGE
87
88   <worksheet name="My Taxes">
89     ... Children here
90   </worksheet>
91
92 In the above example, the children will be executed in the context of the
93 "My Taxes" worksheet.
94
95 =head1 AUTHOR
96
97 Rob Kinyon (rob.kinyon@gmail.com)
98
99 =head1 SEE ALSO
100
101 ROW, CELL, FORMULA
102
103 =cut