Revision history for Perl distribution Excel::Template
X.XX
+ - Add autofilter to worksheet
- Swichting to Module::Install
0.31 Mo Dec 17 13:41:00 2007
=item * Swichting to Module::Install
+=item * Add autofilter to worksheet
+
=back
=head2 Robert Graff
$worksheet->hide_gridlines( $hide_gridlines );
}
+ my $autofilter = $context->get( $self, "AUTOFILTER");
+ if ( defined $autofilter ) {
+ if ($autofilter =~ /^\D/) {
+ $worksheet->autofilter($autofilter);
+ }else{
+ $autofilter =~ s/ //g;
+ my ($row1, $col1, $row2, $col2) = split(',',$autofilter);
+ $worksheet->autofilter($row1, $col1, $row2, $col2);
+ }
+ }
+
return $self->SUPER::render($context);
}
In that example, the first and third worksheets will be landscape (inheriting
it from the workbook node), but the second worksheet will be portrait.
+=item * AUTOFILTER
+
+With these attributes, the auto filter set for the Worksheet.
+See L<Spreadsheet::WriteExcel>->autofilter()
+
+Example:
+ <workbook>
+ <worksheet autofilter='A1:D11' />
+ <worksheet autofilter='0, 0, 10, 3' />
+ </workbook>
+
=back
=head1 CHILDREN
--- /dev/null
+use strict;
+
+use Test::More tests => 4;
+
+use lib 't';
+use mock;
+use Data::Dumper;
+mock::reset;
+
+my $CLASS = 'Excel::Template';
+use_ok( $CLASS );
+
+my $object = $CLASS->new(
+ filename => \*DATA,
+);
+isa_ok( $object, $CLASS );
+
+ok( $object->write_file( 'filename' ), 'Something returned' );
+
+my @calls = mock::get_calls;
+# warn Dumper \@calls;
+is( join( $/, @calls, '' ), <<__END_EXPECTED__, 'Calls match up' );
+Spreadsheet::WriteExcel::new( 'filename' )
+Spreadsheet::WriteExcel::add_format( '' )
+Spreadsheet::WriteExcel::add_worksheet( '' )
+Spreadsheet::WriteExcel::Worksheet::new( '' )
+Spreadsheet::WriteExcel::Worksheet::autofilter( 'A1:D11' )
+Spreadsheet::WriteExcel::add_worksheet( '' )
+Spreadsheet::WriteExcel::Worksheet::new( '' )
+Spreadsheet::WriteExcel::Worksheet::autofilter( '0', '0', '10', '3' )
+Spreadsheet::WriteExcel::close( '' )
+__END_EXPECTED__
+
+__DATA__
+<workbook>
+ <worksheet autofilter='A1:D11' />
+ <worksheet autofilter='0, 0, 10, 3' />
+</workbook>
my @funcs = qw(
write_string write_number write_blank write_url write_formula write_date_time write
set_row set_column keep_leading_zeros insert_bitmap freeze_panes
- set_landscape set_portrait merge_range hide_gridlines
+ set_landscape set_portrait merge_range hide_gridlines autofilter
);
foreach my $func ( @funcs ) {