1 package Excel::Template::Element::Cell;
7 @ISA = qw(Excel::Template::Element);
9 use Excel::Template::Element;
15 my $self = $class->SUPER::new(@_);
17 $self->{TXTOBJ} = Excel::Template::Factory->_create('TEXTOBJECT');
27 my $txt = $context->get($self, 'TEXT');
30 my $txt_obj = Excel::Template::Factory->_create('TEXTOBJECT');
31 push @{$txt_obj->{STACK}}, $txt;
32 $txt = $txt_obj->resolve($context);
34 elsif ($self->{TXTOBJ})
36 $txt = $self->{TXTOBJ}->resolve($context)
40 $txt = $context->use_unicode
41 ? Unicode::String::utf8('')
49 'blank' => 'write_blank',
50 'formula' => 'write_formula',
51 'number' => 'write_number',
52 'string' => 'write_string',
59 my ($context, $method) = @_;
63 my $type = $context->get( $self, 'TYPE' );
68 if ( exists $legal_types{ $type } )
70 $method = $legal_types{ $type };
74 warn "'$type' is not a legal cell type.\n"
82 my ($row, $col) = map { $context->get($self, $_) } qw(ROW COL);
84 my $ref = uc $context->get( $self, 'REF' );
85 if (defined $ref && length $ref)
87 $context->add_reference( $ref, $row, $col );
90 # Apply the cell width to the current column
91 if (my $width = $context->get($self, 'WIDTH'))
97 $context->active_worksheet->set_column($col, $col, $width);
101 $context->active_worksheet->$method(
103 $self->_get_text($context),
104 $context->active_format,
122 Excel::Template::Element::Cell - Excel::Template::Element::Cell
126 To actually write stuff to the worksheet
134 Excel::Template::Element
142 This is the text to write to the cell. This can either be text or a parameter
143 with a dollar-sign in front of the parameter name.
147 Optionally, you can specify which column you want this cell to be in. It can be
148 either a number (zero-based) or an offset. See Excel::Template for more info on
149 offset-based numbering.
153 Adds the current cell to the a list of cells that can be backreferenced.
154 This is useful when the current cell needs to be referenced by a
155 formula. See BACKREF and RANGE.
159 Sets the width of the column the cell is in. The last setting for a given column
164 This allows you to specify what write_*() method will be used. The default is to
165 call write() and let S::WE make the right call. However, you may wish to
166 override it. Excel::Template will not do any form of validation on what you
167 provide. You are assumed to know what you're doing.
185 q.v. L<Spreadsheet::WriteExcel> for more info.
191 Excel::Template::Element::Formula
195 This will consume one column on the current row.
203 <cell text="Some Text Here"/>
204 <cell>Some other text here</cell>
206 <cell text="$Param2"/>
207 <cell>Some <var name="Param"> text here</cell>
209 In the above example, four cells are written out. The first two have text hard-
210 coded. The second two have variables. The third and fourth items have another
211 thing that should be noted. If you have text where you want a variable in the
212 middle, you have to use the latter form. Variables within parameters are the
213 entire parameter's value.
215 Please see Spreadsheet::WriteExcel for what constitutes a legal formula.
219 Rob Kinyon (rob.kinyon@gmail.com)