Intermediate commit - just have to add/fix POD for two classes, then done
[p5sagit/Excel-Template.git] / lib / Excel / Template / Element / Backref.pm
1 package Excel::Template::Element::Backref;
2
3 use strict;
4 use Spreadsheet::WriteExcel::Utility;
5
6 BEGIN {
7     use vars qw(@ISA);
8     @ISA = qw(Excel::Template::Element);
9
10     use Excel::Template::Element;
11 }
12
13 sub resolve
14
15     my $self = shift;
16     my ($context) = @_;
17
18     my $ref_name = $context->resolve($self, 'REF');
19
20     my ($row, $col) = $context->get_last_reference( $ref_name );
21     return '' unless defined $row && defined $col;
22
23     return xl_rowcol_to_cell( $row, $col );
24 }
25
26 1;
27 __END__
28
29 =head1 NAME
30
31 Excel::Template::Element::Backref
32
33 =head1 PURPOSE
34
35 Returns the cell location (i.e. B2) of the last cell to name this reference.  To
36 return the location of the entire range of cells to name this reference see RANGE.
37
38 =head1 NODE NAME
39
40 BACKREF
41
42 =head1 INHERITANCE
43
44 Excel::Template::Element
45
46 =head1 ATTRIBUTES
47
48 =over 4
49
50 =item * REF
51
52 This is the name of the reference to look up.
53
54 =back
55
56 =head1 CHILDREN
57
58 None
59
60 =head1 EFFECTS
61
62 None
63
64 =head1 DEPENDENCIES
65
66 This will only be used within CELL tags.
67
68 =head1 USAGE
69
70 In the example...
71
72   <row>
73     <cell ref="this_cell"/><cell ref="that_cell"><cell ref="that_cell">
74   </row>
75   <row>
76     <formula>=<backref ref="this_cell">+<backref ref="that_cell"></formula>
77   </row>
78
79 The formula in row 2 would be =A1+C1.  C1 is the last to reference "that_cell".
80
81 =head1 AUTHOR
82
83 Rob Kinyon (rkinyon@columbus.rr.com)
84
85 =head1 SEE ALSO
86
87 CELL, RANGE
88
89 =cut