Fixed email address to gmail address
[p5sagit/Excel-Template.git] / lib / Excel / Template / Element / Formula.pm
CommitLineData
d0eafc11 1package Excel::Template::Element::Formula;
2
3use strict;
4
5BEGIN {
6 use vars qw(@ISA);
7 @ISA = qw(Excel::Template::Element::Cell);
8
9 use Excel::Template::Element::Cell;
10}
11
12sub get_text
13{
14 my $self = shift;
15 my ($context) = @_;
16
17 my $text = $self->SUPER::get_text($context);
18
19# At this point, we must do back-reference dereferencing
20
21 return $text;
22}
23
24sub render
25{
26 my $self = shift;
27 my ($context) = @_;
28
29 $context->active_worksheet->write_formula(
30 (map { $context->get($self, $_) } qw(ROW COL)),
31 $self->get_text($context),
32 );
33
34 return 1;
35}
36
371;
38__END__
39
40=head1 NAME
41
42Excel::Template::Element::Formula - Excel::Template::Element::Formula
43
44=head1 PURPOSE
45
46To write formulas to the worksheet
47
48=head1 NODE NAME
49
50FORMULA
51
52=head1 INHERITANCE
53
54Excel::Template::Element::Cell
55
56=head1 ATTRIBUTES
57
58=over 4
59
60=item * TEXT
61
62This is the formula to write to the cell. This can either be text or a parameter
63with a dollar-sign in front of the parameter name.
64
65=item * COL
66
67Optionally, you can specify which column you want this cell to be in. It can be
68either a number (zero-based) or an offset. See Excel::Template for more info on
69offset-based numbering.
70
71=back 4
72
73There will be more parameters added, as features are added.
74
75=head1 CHILDREN
76
77None
78
79=head1 EFFECTS
80
81This will consume one column on the current row.
82
83=head1 DEPENDENCIES
84
85None
86
87=head1 USAGE
88
89 <formula text="=(1 + 2)"/>
90 <formula>=SUM(A1:A5)</formula>
91
92 <formula text="$Param2"/>
93 <formula>=(A1 + <var name="Param">)</formula>
94
95In the above example, four formulas are written out. The first two have the
96formula hard-coded. The second two have variables. The third and fourth items
97have another thing that should be noted. If you have a formula where you want a
98variable in the middle, you have to use the latter form. Variables within
99parameters are the entire parameter's value.
100
101=head1 AUTHOR
102
c09684ff 103Rob Kinyon (rob.kinyon@gmail.com)
d0eafc11 104
105=head1 SEE ALSO
106
107ROW, VAR, CELL
108
109=cut