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);
36 $txt = $self->{TXTOBJ}->resolve($context)
43 'blank' => 'write_blank',
44 'formula' => 'write_formula',
45 'number' => 'write_number',
46 'string' => 'write_string',
48 'date_time' => 'write_date_time',
54 my ($context, $method) = @_;
58 my $type = $context->get( $self, 'TYPE' );
63 if ( exists $legal_types{ $type } )
65 $method = $legal_types{ $type };
69 warn "'$type' is not a legal cell type.\n"
77 my ($row, $col) = map { $context->get($self, $_) } qw(ROW COL);
79 my $ref = $context->get( $self, 'REF' );
80 if (defined $ref && length $ref)
82 $context->add_reference( uc( $ref ), $row, $col );
85 # Apply the cell width to the current column
86 if (my $width = $context->get($self, 'WIDTH'))
88 $width =~ s/[^\d.]//g;
92 $context->active_worksheet->set_column($col, $col, $width);
96 $context->active_worksheet->$method(
98 $self->_get_text($context),
99 $context->active_format,
102 my $comment = $context->get($self, 'COMMENT');
103 if (defined $comment && length $comment){
104 $context->active_worksheet->write_comment($row, $col,$comment);
122 Excel::Template::Element::Cell - Excel::Template::Element::Cell
126 To actually write stuff to the worksheet
134 L<ELEMENT|Excel::Template::Element>
142 This is the text to write to the cell. This can either be text or a parameter with a dollar-sign in front of the parameter name.
146 Optionally, you can specify which column you want this cell to be in. It can be either a number (zero-based) or an offset. See L<Excel::Template> for more info on offset-based numbering.
150 Adds the current cell to the a list of cells that can be backreferenced. This is useful when the current cell needs to be referenced by a formula. See L<BACKREF|Excel::Tepmlate::Element::Backref> and L<RANGE|Excel::Tepmlate::Container::Range>.
154 Sets the width of the column the cell is in. The last setting for a given column
159 This allows you to specify what write_*() method will be used. The default is to call write() and let L<Spreadsheet::WriteExcel> make the right call. However, you may wish to override it. L<Excel::Template> will not do any form of validation on what you provide. You are assumed to know what you're doing.
161 The legal types (taken from L<Spreadsheet::WriteExcel>) are:
165 Add a comment to the cell
183 other write_* methods as defined defined L<Spreadsheet::WriteExcel> would be integrated by request
189 L<FORMULA|Excel::Template::Element::Formula>
193 This will consume one column in the current row.
201 <cell text="Some Text Here"/>
202 <cell>Some other text here</cell>
204 <cell text="$Param2"/>
205 <cell>Some <var name="Param"> text here</cell>
207 In the above example, four cells are written out. The first two have text hard-coded. The second two have variables. The third and fourth items have another thing that should be noted. If you have text where you want a variable in the middle, you have to use the latter form. Variables within parameters are the entire parameter's value.
209 Please see L<Spreadsheet::WriteExcel> for what constitutes a legal formula.
213 Rob Kinyon (rob.kinyon@gmail.com)
217 L<ROW|Excel::Template::Container::Row>, L<VAR|Excel::Template::Element::Var>, L<FORMULA|Excel::Template::Element::Formula>