Excel-Template

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

    - Fixed several bugs in formats found by building tests
      - HIDDEN node now actually works
      - LOCKED node now actually works

0.15 Thu Nov 04 16:15:00 2004
    - Fixed bugs that were:
        - preventing a worksheet from using a variable name in a loop
        - allowing two worksheets to have the same name
        - preventing a worksheet from being called '0' or '0.0'
    - Added back-references. This allows for one cell to refer to another
      cell in an Excel-aware way, especially in formulas.
    - Added the following nodes:
        - BACKREF
        - RANGE

0.14 Thu Nov 04 13:30:00 2004
    - Added new format support for (nearly) all formats supported by
      Spreadsheet::WriteExcel
    - Fixed email address everywhere

0.13 Thu Oct 29 07:30:00 2004

Changes  view on Meta::CPAN

0.09 Mon Feb 02 16:00:00 2004
    - Fixed bug with multiple worksheets

0.08 Fri Jan 30 14:00:00 2004
    - Added Base to the params for XML::Parser to allow for entity includes

0.07 Fri Jan 23 08:30:00 2004
    - Fixed the MANIFEST to account for missing files

0.06 Mon Jan 20 11:00:00 2004
    - Added formulas (no back-references yet)
    - Improved POD a little

0.05 Wed Jan 16 12:30:00 2004
    - Fixed a bug in formats

0.04 Wed Jan 16 12:00:00 2004
    - Added BIG_FILES as an option, which will use
      Spreadsheet::WriteExcel::Big as the renderer (yet unimplemented)
    - Changed the output() method to use a tied IO::Scalar (which is
      now a requirement.

MANIFEST  view on Meta::CPAN

t/003_worksheet.t
t/004.xml
t/004_cell.t
t/005.xml
t/005_formats.t
t/006.xml
t/006_variables.t
t/007.xml
t/007_cell_formats.t
t/008.xml
t/008_formula.t
t/009.xml
t/009_loop.t
t/010.xml
t/010_scope.t
t/011.xml
t/011_conditional.t
t/012.xml
t/012_backref.t
t/013.xml
t/013_range.t

lib/Excel/Template.pm  view on Meta::CPAN

=item * L<BACKREF|Excel::Template::Element::Backref>

This refers back to a cell previously named.

=item * L<CELL|Excel::Template::Element::Cell>

This is the actual cell in a spreadsheet.

=item * L<FORMULA|Excel::Template::Element::Formula>

This is a formula in a spreadsheet.

=item * L<RANGE|Excel::Template::Element::Range>

This is a BACKREF for a number of identically-named cells.

=item * L<VAR|Excel::Template::Element::Var>

This is a variable. It is generally used when the 'text' attribute isn't
sufficient.

lib/Excel/Template/Element/Backref.pm  view on Meta::CPAN

This will only be used within CELL tags.

=head1 USAGE

In the example...

  <row>
    <cell ref="this_cell"/><cell ref="that_cell"><cell ref="that_cell">
  </row>
  <row>
    <formula>=<backref ref="this_cell">+<backref ref="that_cell"></formula>
  </row>

The formula in row 2 would be =A1+C1.  C1 is the last to reference "that_cell".

=head1 AUTHOR

Rob Kinyon (rkinyon@columbus.rr.com)

=head1 SEE ALSO

CELL, RANGE

=cut

lib/Excel/Template/Element/Cell.pm  view on Meta::CPAN

    else
    {
        $txt = $self->{TXTOBJ}->resolve($context)
    }

    return $txt;
}

my %legal_types = (
    'blank'     => 'write_blank',
    'formula'   => 'write_formula',
    'number'    => 'write_number',
    'string'    => 'write_string',
    'url'       => 'write_url',
    'date_time' => 'write_date_time',
);

sub render
{
    my $self = shift;
    my ($context, $method) = @_;

lib/Excel/Template/Element/Cell.pm  view on Meta::CPAN

=item * TEXT

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.

=item * COL

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.

=item * REF

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>.

=item * WIDTH

Sets the width of the column the cell is in. The last setting for a given column
will win out.

=item * TYPE

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 ...

The legal types (taken from L<Spreadsheet::WriteExcel>) are:

=item * COMMENT

Add a comment to the cell

=over 4

=item * blank

=item * formula

=item * number

=item * string

=item * url

=item * date_time

=back

lib/Excel/Template/Element/Cell.pm  view on Meta::CPAN

=head1 USAGE

  <cell text="Some Text Here"/>
  <cell>Some other text here</cell>

  <cell text="$Param2"/>
  <cell>Some <var name="Param"> text here</cell>

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 hav...

Please see L<Spreadsheet::WriteExcel> for what constitutes a legal formula.

=head1 AUTHOR

Rob Kinyon (rob.kinyon@gmail.com)

=head1 SEE ALSO

L<ROW|Excel::Template::Container::Row>, L<VAR|Excel::Template::Element::Var>, L<FORMULA|Excel::Template::Element::Formula>

=cut

lib/Excel/Template/Element/Formula.pm  view on Meta::CPAN


use strict;

BEGIN {
    use vars qw(@ISA);
    @ISA = qw(Excel::Template::Element::Cell);

    use Excel::Template::Element::Cell;
}

sub render { $_[0]->SUPER::render( $_[1], 'write_formula' ) }
#{
#    my $self = shift;
#    my ($context) = @_;
#
#    return $self->SUPER::render( $context, 'write_formula' );
#}

1;
__END__

=head1 NAME

Excel::Template::Element::Formula - Excel::Template::Element::Formula

=head1 PURPOSE

To write formulas to the worksheet

=head1 NODE NAME

FORMULA

=head1 INHERITANCE

Excel::Template::Element::Cell

=head1 ATTRIBUTES

lib/Excel/Template/Element/Formula.pm  view on Meta::CPAN

=head1 EFFECTS

This will consume one column on the current row. 

=head1 DEPENDENCIES

None

=head1 USAGE

  <formula text="=(1 + 2)"/>
  <formula>=SUM(A1:A5)</formula>

  <formula text="$Param2"/>
  <formula>=(A1 + <var name="Param">)</formula>

In the above example, four formulas are written out. The first two have the
formula hard-coded. The second two have variables. The third and fourth items
have another thing that should be noted. If you have a formula where you want a
variable in the middle, you have to use the latter form. Variables within
parameters are the entire parameter's value.

=head1 AUTHOR

Rob Kinyon (rob.kinyon@gmail.com)

=head1 SEE ALSO

CELL

lib/Excel/Template/Element/Range.pm  view on Meta::CPAN

This will only be used within CELL tags.

=head1 USAGE

In the example...

  <row>
    <cell ref="this_cell"/><cell ref="that_cell"><cell ref="that_cell">
  </row>
  <row>
    <formula>=SUM(<range ref="that_cell">)</formula>
  </row>

The formula in row 2 would be =SUM(B1:C1).

=head1 AUTHOR

Rob Kinyon (rkinyon@columbus.rr.com)

=head1 SEE ALSO

CELL, BACKREF

=cut

t/008.xml  view on Meta::CPAN

<workbook>
  <worksheet name="formula">
    <formula>Test1</formula>
    <formula text="Test2" />
    <formula />
  </worksheet>
</workbook>

t/008_formula.t  view on Meta::CPAN

    filename => 't/008.xml',
);
isa_ok( $object, $CLASS );

ok( $object->write_file( 'filename' ), 'Something returned' );

my @calls = mock::get_calls;
is( join( $/, @calls, '' ), <<__END_EXPECTED__, 'Calls match up' );
Spreadsheet::WriteExcel::new( 'filename' )
Spreadsheet::WriteExcel::add_format( '' )
Spreadsheet::WriteExcel::add_worksheet( 'formula' )
Spreadsheet::WriteExcel::Worksheet::new( '' )
Spreadsheet::WriteExcel::Worksheet::write_formula( '0', '0', 'Test1', '1' )
Spreadsheet::WriteExcel::Worksheet::write_formula( '0', '1', 'Test2', '1' )
Spreadsheet::WriteExcel::Worksheet::write_formula( '0', '2', '', '1' )
Spreadsheet::WriteExcel::close( '' )
__END_EXPECTED__

t/015.xml  view on Meta::CPAN

<workbook>
  <worksheet name="cell_type">
    <cell type="string">String</cell>
    <cell type="number">Number</cell>
    <cell type="blank">Blank</cell>
    <cell type="url">URL</cell>
    <cell type="formula">Formula</cell>
    <cell type="date_time">DateTime</cell>
   </worksheet>
</workbook>

t/015_cell_type.t  view on Meta::CPAN

my @calls = mock::get_calls;
is( join( $/, @calls, '' ), <<__END_EXPECTED__, 'Calls match up' );
Spreadsheet::WriteExcel::new( 'filename' )
Spreadsheet::WriteExcel::add_format( '' )
Spreadsheet::WriteExcel::add_worksheet( 'cell_type' )
Spreadsheet::WriteExcel::Worksheet::new( '' )
Spreadsheet::WriteExcel::Worksheet::write_string( '0', '0', 'String', '1' )
Spreadsheet::WriteExcel::Worksheet::write_number( '0', '1', 'Number', '1' )
Spreadsheet::WriteExcel::Worksheet::write_blank( '0', '2', 'Blank', '1' )
Spreadsheet::WriteExcel::Worksheet::write_url( '0', '3', 'URL', '1' )
Spreadsheet::WriteExcel::Worksheet::write_formula( '0', '4', 'Formula', '1' )
Spreadsheet::WriteExcel::Worksheet::write_date_time( '0', '5', 'DateTime', '1' )
Spreadsheet::WriteExcel::close( '' )
__END_EXPECTED__

t/Spreadsheet/WriteExcel/Worksheet.pm  view on Meta::CPAN


    {
        local $" = "', '";
        push @mock::calls, __PACKAGE__ . "::new( '@_' )";
    }

    return $self;
}

my @funcs = qw(
    write_string write_number write_blank write_url write_formula write_date_time write
    set_row set_column keep_leading_zeros insert_bitmap freeze_panes
    set_landscape set_portrait merge_range hide_gridlines autofilter write_comment
);

foreach my $func ( @funcs ) {
    no strict 'refs';
    *$func = sub {
        my $self = shift;
        local $" = "', '";
        push @mock::calls, __PACKAGE__ . "::${func}( '@_' )";



( run in 0.324 second using v1.01-cache-2.11-cpan-26ccb49234f )