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 my ($top, $left, $bottom, $right) =
27 ( $refs[0][0], $refs[0][1] ) x 2;
30 foreach my $ref ( @refs )
32 $top = min( $top, $ref->[0]);
33 $bottom = max( $bottom, $ref->[0]);
34 $left = min( $left, $ref->[1]);
35 $right = max( $right, $ref->[1]);
39 xl_rowcol_to_cell($top, $left),
40 xl_rowcol_to_cell($bottom, $right)
49 Excel::Template::Element::Range
53 Returns a range of cell locations (i.e. B2:C2) that contains all calls using
54 this reference. To return the location of the last cell, use BACKREF.
62 Excel::Template::Element
70 This is the name of the reference to look up.
84 This will only be used within CELL tags.
91 <cell ref="this_cell"/><cell ref="that_cell"><cell ref="that_cell">
94 <formula>=SUM(<range ref="that_cell">)</formula>
97 The formula in row 2 would be =SUM(B1:C1).
101 Rob Kinyon (rkinyon@columbus.rr.com)