1 package Excel::Template::Element::Range;
4 use Spreadsheet::WriteExcel::Utility;
8 @ISA = qw(Excel::Template::Element);
10 use Excel::Template::Element;
13 sub min { $_[0] < $_[1] ? $_[0] : $_[1] }
14 sub max { $_[0] > $_[1] ? $_[0] : $_[1] }
21 my $ref_name = $context->resolve($self, 'REF');
23 my @refs = $context->get_all_references( $ref_name );
24 return '' unless @refs;
26 return $self->_join_refs(@refs);
30 my ($self, @refs) = @_;
32 my ($top, $left, $bottom, $right) =
33 ( $refs[0][0], $refs[0][1] ) x 2;
36 foreach my $ref ( @refs )
38 $top = min( $top, $ref->[0]);
39 $bottom = max( $bottom, $ref->[0]);
40 $left = min( $left, $ref->[1]);
41 $right = max( $right, $ref->[1]);
45 xl_rowcol_to_cell($top, $left),
46 xl_rowcol_to_cell($bottom, $right)
55 Excel::Template::Element::Range - Excel::Template::Element::Range
59 Returns a range of cell locations (i.e. B2:C2) that contains all calls using
60 this reference. To return the location of the last cell, use BACKREF.
68 Excel::Template::Element
76 This is the name of the reference to look up.
90 This will only be used within CELL tags.
97 <cell ref="this_cell"/><cell ref="that_cell"><cell ref="that_cell">
100 <formula>=SUM(<range ref="that_cell">)</formula>
103 The formula in row 2 would be =SUM(B1:C1).
107 Rob Kinyon (rkinyon@columbus.rr.com)