X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FExcel%2FTemplate.pm;h=aac94bc34de63f0ee701389075159239c845199f;hb=bc42be6f49f58822e4011f7bba9b882533a8295f;hp=cf484ef34d239b0b4996d4523a83b12b6e023e29;hpb=e976988f30574c0c21cfa29fc5d080827e003fb6;p=p5sagit%2FExcel-Template.git diff --git a/lib/Excel/Template.pm b/lib/Excel/Template.pm index cf484ef..aac94bc 100644 --- a/lib/Excel/Template.pm +++ b/lib/Excel/Template.pm @@ -6,7 +6,7 @@ BEGIN { use Excel::Template::Base; use vars qw ($VERSION @ISA); - $VERSION = '0.23'; + $VERSION = '0.33'; @ISA = qw( Excel::Template::Base ); } @@ -86,7 +86,7 @@ sub param my $self = shift; # Allow an arbitrary number of hashrefs, so long as they're the first things # into param(). Put each one onto the end, de-referenced. - push @_, %{shift @_} while UNIVERSAL::isa($_[0], 'HASH'); + push @_, %{shift @_} while ref $_[0] eq 'HASH'; (@_ % 2) && die __PACKAGE__, "->param() : Odd number of parameters to param()\n"; @@ -106,10 +106,15 @@ sub write_file my $xls = $self->{RENDERER}->new($filename) || die "Cannot create XLS in '$filename': $!\n"; - $self->_prepare_output($xls); + eval { + $self->_prepare_output($xls); + }; +print $@ if $@; $xls->close; + return if $@; + return ~~1; } @@ -120,7 +125,8 @@ sub output my $output; tie *XLS, 'IO::Scalar', \$output; - $self->write_file(\*XLS); + $self->write_file(\*XLS) + or return; return $output; } @@ -143,18 +149,18 @@ sub parse_xml if ( $node->isa( 'WORKBOOK' ) ) { - push @{$self->{WORKBOOKS}}, $node; + $self->{WORKBOOK} = $node; } elsif ( $node->is_embedded ) { return unless @stack; - + if (exists $stack[-1]{TXTOBJ} && $stack[-1]{TXTOBJ}->isa('TEXTOBJECT')) { push @{$stack[-1]{TXTOBJ}{STACK}}, $node; } - + } else { @@ -193,29 +199,37 @@ sub parse_xml else { my ($filename, $dirname) = fileparse($file); - - push @parms, Base => $dirname; - open( INFILE, "<$file" ) - || die "Cannot open '$file' for reading: $!\n"; + push @parms, Base => $dirname; + eval q{ + open( INFILE, '<', $file ) + || die "Cannot open '$file' for reading: $!\n"; + }; if ( $@ ) { + if ( $@ =~ /Too many arguments for open/ ) { + open( INFILE, "< $file" ) + || die "Cannot open '$file' for reading: $!\n"; + } else { + die $@; + } + } } my $parser = XML::Parser->new( @parms ); $parser->parse(do { local $/ = undef; }); - unless ( ref $file ) - { - close INFILE; - } + close INFILE + unless ref $file; return ~~1; } -*parse = \&parse_xml; +*parse = *parse = \&parse_xml; sub _prepare_output { my $self = shift; + return unless $self->{WORKBOOK}; + my ($xls) = @_; my $context = Excel::Template::Factory->_create( @@ -226,7 +240,7 @@ sub _prepare_output UNICODE => $self->{UNICODE}, ); - $_->render($context) for @{$self->{WORKBOOKS}}; + $self->{WORKBOOK}->render($context); return ~~1; } @@ -399,7 +413,7 @@ This node represents a loop. It behaves just like L's TMPL_LOOP. =item * L -This node represents a row of data. This is the A in A1. +This node represents a row of data. This is the 1 in A1. There is no COLUMN node, as of yet. =item * L @@ -436,14 +450,26 @@ None, that I know of. This is production quality software, used in several production web applications. -=head1 AUTHOR +=head1 MAINTAINERS - Rob Kinyon (rob.kinyon@gmail.com) + Jens Gassmann + Robert Bohne + Rob Kinyon =head1 CONTRIBUTORS There is a mailing list at http://groups.google.com/group/ExcelTemplate or exceltemplate@googlegroups.com +=head2 Robert Bohne + +=over 4 + +=item * Swichting to Module::Install + +=item * Add autofilter to worksheet + +=back + =head2 Robert Graff =over 4 @@ -454,45 +480,56 @@ There is a mailing list at http://groups.google.com/group/ExcelTemplate or excel =back +=head2 Jens Gassmann + +=over 4 + +=item * Add hide_gridlines to worksheet + +=back + =head1 TEST COVERAGE -I used L to test the coverage of my tests. Every release, I intend to improve these numbers. +I use L to test the coverage of my tests. Every release, I intend to improve these numbers. Excel::Template is also part of the CPAN Kwalitee initiative, being one of the top 100 non-core modules downloaded from CPAN. If you wish to help out, please feel free to contribute tests, patches, and/or suggestions. - ----------------------------------------------------------------------- - File stmt brnch cond sub pod time total - ----------------------------------------------------------------------- - blib/lib/Excel/Template.pm 96.0 62.5 58.8 100.0 100.0 25.2 86.2 - ...ib/Excel/Template/Base.pm 87.0 50.0 66.7 81.8 87.5 8.7 83.0 - ...cel/Template/Container.pm 71.4 50.0 33.3 70.0 80.0 4.9 68.4 - ...emplate/Container/Bold.pm 100.0 n/a n/a 100.0 0.0 0.7 95.0 - .../Container/Conditional.pm 64.9 57.5 66.7 100.0 0.0 0.7 63.9 - ...plate/Container/Format.pm 100.0 n/a n/a 100.0 0.0 0.7 96.6 - ...plate/Container/Hidden.pm 100.0 n/a n/a 100.0 0.0 0.1 95.0 - ...plate/Container/Italic.pm 100.0 n/a n/a 100.0 0.0 0.1 95.0 - ...plate/Container/Locked.pm 100.0 n/a n/a 100.0 0.0 0.1 95.0 - ...emplate/Container/Loop.pm 90.9 50.0 50.0 100.0 50.0 0.5 80.4 - ...late/Container/Outline.pm 100.0 n/a n/a 100.0 0.0 0.1 95.0 - ...Template/Container/Row.pm 100.0 75.0 n/a 100.0 50.0 0.3 93.8 - ...mplate/Container/Scope.pm 100.0 n/a n/a 100.0 n/a 0.1 100.0 - ...plate/Container/Shadow.pm 100.0 n/a n/a 100.0 0.0 0.1 95.0 - ...te/Container/Strikeout.pm 100.0 n/a n/a 100.0 0.0 0.1 95.0 - ...ate/Container/Workbook.pm 100.0 n/a n/a 100.0 n/a 0.9 100.0 - ...te/Container/Worksheet.pm 94.1 50.0 n/a 100.0 0.0 0.9 88.0 - ...Excel/Template/Context.pm 84.3 53.4 54.2 100.0 92.3 19.5 76.0 - ...Excel/Template/Element.pm 100.0 n/a n/a 100.0 n/a 0.5 100.0 - ...mplate/Element/Backref.pm 100.0 50.0 33.3 100.0 0.0 0.1 87.1 - .../Template/Element/Cell.pm 95.8 65.0 80.0 100.0 66.7 3.8 86.9 - ...mplate/Element/Formula.pm 100.0 n/a n/a 100.0 0.0 0.3 94.1 - ...Template/Element/Range.pm 100.0 66.7 n/a 100.0 66.7 0.2 93.3 - ...l/Template/Element/Var.pm 100.0 n/a n/a 100.0 0.0 0.1 94.1 - ...Excel/Template/Factory.pm 100.0 73.1 n/a 100.0 100.0 16.3 92.6 - .../Excel/Template/Format.pm 98.3 81.2 33.3 100.0 100.0 10.0 93.2 - ...xcel/Template/Iterator.pm 98.6 80.0 70.6 100.0 83.3 1.9 90.3 - ...el/Template/TextObject.pm 92.9 62.5 33.3 100.0 50.0 3.1 83.0 - Total 92.0 63.5 58.3 97.5 98.5 100.0 86.0 - ----------------------------------------------------------------------- + ---------------------------- ------ ------ ------ ------ ------ ------ ------ + File stmt bran cond sub pod time total + ---------------------------- ------ ------ ------ ------ ------ ------ ------ + blib/lib/Excel/Template.pm 93.8 60.0 58.8 100.0 100.0 31.8 83.3 + ...ib/Excel/Template/Base.pm 94.4 50.0 n/a 100.0 0.0 4.4 80.0 + ...cel/Template/Container.pm 100.0 50.0 33.3 100.0 0.0 2.0 83.3 + ...emplate/Container/Bold.pm 100.0 n/a n/a 100.0 0.0 0.1 95.0 + .../Container/Conditional.pm 95.9 90.0 66.7 100.0 0.0 0.3 91.0 + ...plate/Container/Format.pm 100.0 n/a n/a 100.0 0.0 1.5 96.8 + ...plate/Container/Hidden.pm 100.0 n/a n/a 100.0 0.0 0.0 95.0 + ...plate/Container/Italic.pm 100.0 n/a n/a 100.0 0.0 0.0 95.0 + ...ainer/KeepLeadingZeros.pm 100.0 100.0 n/a 100.0 0.0 0.0 96.3 + ...plate/Container/Locked.pm 100.0 n/a n/a 100.0 0.0 0.0 95.0 + ...emplate/Container/Loop.pm 96.8 50.0 50.0 100.0 0.0 0.1 82.7 + ...late/Container/Outline.pm 100.0 n/a n/a 100.0 0.0 0.0 95.0 + ...Template/Container/Row.pm 100.0 75.0 n/a 100.0 0.0 0.1 90.6 + ...mplate/Container/Scope.pm 100.0 n/a n/a 100.0 n/a 0.0 100.0 + ...plate/Container/Shadow.pm 100.0 n/a n/a 100.0 0.0 0.0 95.0 + ...te/Container/Strikeout.pm 100.0 n/a n/a 100.0 0.0 0.0 95.0 + ...ate/Container/Workbook.pm 100.0 n/a n/a 100.0 n/a 7.0 100.0 + ...te/Container/Worksheet.pm 95.5 87.5 100.0 100.0 0.0 1.1 90.2 + ...Excel/Template/Context.pm 98.0 80.0 75.0 100.0 73.3 17.0 90.7 + ...Excel/Template/Element.pm 100.0 n/a n/a 100.0 n/a 0.1 100.0 + ...mplate/Element/Backref.pm 100.0 50.0 33.3 100.0 0.0 0.1 87.1 + .../Template/Element/Cell.pm 97.9 75.0 80.0 100.0 0.0 5.6 88.6 + ...mplate/Element/Formula.pm 100.0 n/a n/a 100.0 0.0 0.0 94.1 + ...te/Element/FreezePanes.pm 100.0 n/a n/a 100.0 0.0 0.0 95.5 + ...Template/Element/Image.pm 100.0 100.0 n/a 100.0 0.0 0.0 94.3 + ...Template/Element/Range.pm 100.0 66.7 n/a 100.0 0.0 0.1 88.9 + ...l/Template/Element/Var.pm 100.0 n/a n/a 100.0 0.0 0.0 94.1 + ...Excel/Template/Factory.pm 100.0 73.1 66.7 100.0 100.0 22.3 91.4 + .../Excel/Template/Format.pm 98.4 75.0 33.3 100.0 66.7 2.6 90.5 + ...xcel/Template/Iterator.pm 98.6 80.0 70.6 100.0 50.0 0.3 88.8 + ...el/Template/TextObject.pm 92.9 62.5 33.3 100.0 0.0 3.3 80.9 + Total 97.8 74.7 64.6 100.0 35.7 100.0 89.4 + ---------------------------- ------ ------ ------ ------ ------ ------ ------ =head1 COPYRIGHT