use Excel::Template::Base;
use vars qw ($VERSION @ISA);
- $VERSION = '0.23';
+ $VERSION = '0.24';
@ISA = qw( Excel::Template::Base );
}
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";
my $xls = $self->{RENDERER}->new($filename)
|| die "Cannot create XLS in '$filename': $!\n";
- $self->_prepare_output($xls);
+ eval {
+ $self->_prepare_output($xls);
+ };
$xls->close;
+ return if $@;
+
return ~~1;
}
my $output;
tie *XLS, 'IO::Scalar', \$output;
- $self->write_file(\*XLS);
+ $self->write_file(\*XLS)
+ or return;
return $output;
}
if ( $node->isa( 'WORKBOOK' ) )
{
- push @{$self->{WORKBOOKS}}, $node;
+ $self->{WORKBOOK} = $node;
}
elsif ( $node->is_embedded )
{
my $parser = XML::Parser->new( @parms );
$parser->parse(do { local $/ = undef; <INFILE> });
- 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(
UNICODE => $self->{UNICODE},
);
- $_->render($context) for @{$self->{WORKBOOKS}};
+ $self->{WORKBOOK}->render($context);
return ~~1;
}