Excel::Template::Container::KeepLeadingZeros - Excel::Template::Container::KeepLeadingZeros


Excel-Template documentation Contained in the Excel-Template distribution.

Index


Code Index:

NAME

Top

Excel::Template::Container::KeepLeadingZeros - Excel::Template::Container::KeepLeadingZeros

PURPOSE

Top

To set the keep_leading_zeros flag for the surrounding worksheet or any worksheets that might be contained within this node.

NODE NAME

Top

KEEP_LEADING_ZEROS

INHERITANCE

Top

CONTAINER

ATTRIBUTES

Top

None

CHILDREN

Top

None

EFFECTS

Top

Alters how leading zeros are interpreted by Spreadsheet::WriteExcel.

DEPENDENCIES

Top

None

USAGE

Top

  <worksheet>
    ... Cells here will NOT have leading-zeros preserved
    <keep_leading_zeros>
      ... Cells here will have leading-zeros preserved
    </keep_leading_zeros>
    ... Cells here will NOT have leading-zeros preserved
  </worksheet>

  <keep_leading_zeros>
    <worksheet>
      ... Cells here will have leading-zeros preserved
    </worksheet>
    <worksheet>
      ... Cells here will have leading-zeros preserved
    </worksheet>
  </keep_leading_zeros>

AUTHOR

Top

Rob Kinyon (rob.kinyon@gmail.com)

SEE ALSO

Top

CELL, Spreadsheet::WriteExcel


Excel-Template documentation Contained in the Excel-Template distribution.

package Excel::Template::Container::KeepLeadingZeros;

use strict;

BEGIN {
    use vars qw(@ISA);
    @ISA = qw(Excel::Template::Container);

    use Excel::Template::Container;
}

sub render
{
    my $self = shift;
    my ($context) = @_;

    my $worksheet = $context->active_worksheet;

    $worksheet
        ? $worksheet->keep_leading_zeros( 1 )
        : $context->mark( keep_leading_zeros => 1 );

    my $rv = $self->SUPER::render($context);

    $worksheet
        ? $worksheet->keep_leading_zeros( 0 )
        : $context->mark( keep_leading_zeros => 0 );

    return $rv;
}

1;
__END__