| 1 | package Excel::Template::Element::MergeRange; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | BEGIN { | ||||||||||
| 6 | 1 | ▶ | use vars qw(@ISA); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | @ISA = qw(Excel::Template::Element); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 1 | ▶ | use Excel::Template::Element; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use Excel::Template::Element::Range; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | } | ||||||||||
| 12 | |||||||||||
| 13 | sub render { | ||||||||||
| 14 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
render: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 15 | 0 | my ($context) = @_; | |||||||||
| 16 | |||||||||||
| 17 | 0 | my $ref_name = $context->resolve($self, 'REF'); | |||||||||
| 18 | |||||||||||
| 19 | 0 | my @refs = $context->get_all_references( $ref_name ); | |||||||||
| 20 | 0 | ▶ | (@refs) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | || die "You must specify a ref for MERGE_RANGE"; | ||||||||||
| 22 | |||||||||||
| 23 | 0 | my $range = Excel::Template::Element::Range->_join_refs(@refs); | |||||||||
| 24 | |||||||||||
| 25 | # NOTE: | ||||||||||
| 26 | # we need to copy the current format | ||||||||||
| 27 | # because Spreadsheet::WriteExcel will | ||||||||||
| 28 | # mark any format used in a merged cell | ||||||||||
| 29 | # as being specifically for a merged cell | ||||||||||
| 30 | # and therefore not usable elsewhere. | ||||||||||
| 31 | |||||||||||
| 32 | 0 | my $old_format = $context->active_format; | |||||||||
| 33 | |||||||||||
| 34 | 0 | my %values; | |||||||||
| 35 | 0 | ▶ | while ( my ($k, $v) = each %$self ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 0 | $values{$k} = $context->resolve( $self, $k ); | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 0 | my $format = $context->format_object->copy( | |||||||||
| 40 | $context, $old_format, %values, | ||||||||||
| 41 | ); | ||||||||||
| 42 | 0 | $context->active_format($format); | |||||||||
| 43 | |||||||||||
| 44 | 0 | $context->active_worksheet->merge_range( | |||||||||
| 45 | $range, | ||||||||||
| 46 | $context->get($self, 'TEXT'), | ||||||||||
| 47 | $format, | ||||||||||
| 48 | ); | ||||||||||
| 49 | |||||||||||
| 50 | 0 | $context->active_format($old_format); | |||||||||
| 51 | |||||||||||
| 52 | 0 | return 1; | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 1 | 1; | |||||||||
| 56 | __END__ | ||||||||||