1 package Excel::Template::Container::Worksheet;
7 @ISA = qw(Excel::Template::Container);
9 use Excel::Template::Container;
12 sub exit_scope { $_[1]->active_worksheet(undef) }
18 my $worksheet = $context->new_worksheet($self);
20 my $password = $context->get( $self, 'PROTECT' );
21 if ( defined $password ) {
22 $worksheet->protect($password);
25 $worksheet->keep_leading_zeros(1)
26 if $context->mark('keep_leading_zeros');
28 if ( $context->get( $self, 'LANDSCAPE' ) && !$self->{PORTRAIT} ) {
29 $worksheet->set_landscape;
30 } elsif ( $context->get( $self, 'PORTRAIT' ) ) {
31 $worksheet->set_portrait;
35 my $hide_gridlines = $context->get( $self, 'HIDE_GRIDLINES');
37 if ( defined $hide_gridlines ) {
38 $worksheet->hide_gridlines( $hide_gridlines );
41 my $autofilter = $context->get( $self, "AUTOFILTER");
42 if ( defined $autofilter ) {
43 if ($autofilter =~ /^\D/) {
44 $worksheet->autofilter($autofilter);
46 $autofilter =~ s/ //g;
47 my ($row1, $col1, $row2, $col2) = split(',',$autofilter);
48 $worksheet->autofilter($row1, $col1, $row2, $col2);
52 return $self->SUPER::render($context);
60 Excel::Template::Container::Worksheet - Excel::Template::Container::Worksheet
64 To provide a new worksheet.
72 Excel::Template::Container
80 This is the name of the worksheet to be added.
84 If the attribute exists, it will mark the worksheet as being protected. Whatever
85 value is set will be used as the password.
87 This activates the HIDDEN and LOCKED nodes.
89 =item * KEEP_LEADING_ZEROS
91 This will change the behavior of the worksheet to preserve leading zeros.
96 his method is used to hide the gridlines on the screen and printed page.
97 Gridlines are the lines that divide the cells on a worksheet. Screen and printed gridlines are
98 turned on by default in an Excel worksheet. If you have defined your own cell
99 borders you may wish to hide the default gridlines.
101 $worksheet->hide_gridlines();
103 The following values of $option are valid:
105 0 : Don't hide gridlines
106 1 : Hide printed gridlines only
107 2 : Hide screen and printed gridlines
109 If you don't supply an argument or use undef the default option is 1, i.e. only the printed gridlines are hidden.
113 This will set the worksheet's orientation to landscape.
117 This will set the worksheet's orientation to portrait.
119 While this is the default, it's useful to override the default at times. For
120 example, in the following situation:
122 <workbook landscape="1">
126 <worksheet portrait="1">
134 In that example, the first and third worksheets will be landscape (inheriting
135 it from the workbook node), but the second worksheet will be portrait.
139 With these attributes, the auto filter set for the Worksheet.
140 See L<Spreadsheet::WriteExcel>->autofilter()
144 <worksheet autofilter='A1:D11' />
145 <worksheet autofilter='0, 0, 10, 3' />
164 <worksheet name="My Taxes">
168 In the above example, the children will be executed in the context of the
169 "My Taxes" worksheet.
173 Rob Kinyon (rob.kinyon@gmail.com)