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',
53 my ($context, $method) = @_;
57 my $type = $context->get( $self, 'TYPE' );
62 if ( exists $legal_types{ $type } )
64 $method = $legal_types{ $type };
68 warn "'$type' is not a legal cell type.\n"
76 my ($row, $col) = map { $context->get($self, $_) } qw(ROW COL);
78 my $ref = $context->get( $self, 'REF' );
79 if (defined $ref && length $ref)
81 $context->add_reference( uc( $ref ), $row, $col );
84 # Apply the cell width to the current column
85 if (my $width = $context->get($self, 'WIDTH'))
87 $width =~ s/[^\d.]//g;
91 $context->active_worksheet->set_column($col, $col, $width);
95 $context->active_worksheet->$method(
97 $self->_get_text($context),
98 $context->active_format,
116 Excel::Template::Element::Cell - Excel::Template::Element::Cell
120 To actually write stuff to the worksheet
128 L<ELEMENT|Excel::Template::Element>
136 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.
140 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.
144 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>.
148 Sets the width of the column the cell is in. The last setting for a given column
153 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.
155 The legal types (taken from L<Spreadsheet::WriteExcel>) are:
171 q.v. L<Spreadsheet::WriteExcel> for more info.
177 L<FORMULA|Excel::Template::Element::Formula>
181 This will consume one column in the current row.
189 <cell text="Some Text Here"/>
190 <cell>Some other text here</cell>
192 <cell text="$Param2"/>
193 <cell>Some <var name="Param"> text here</cell>
195 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.
197 Please see L<Spreadsheet::WriteExcel> for what constitutes a legal formula.
201 Rob Kinyon (rob.kinyon@gmail.com)
205 L<ROW|Excel::Template::Container::Row>, L<VAR|Excel::Template::Element::Var>, L<FORMULA|Excel::Template::Element::Formula>