Data-Tabular

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

0.26 Sat Jun 10 08:44:46 EDT 2006
        - Remvoed spell.t as it fails on many systems and is only need
          for development.
        - Skipping in t/spreadsheet.t was not correct.
	- removed references to Data::Tabular::XML as it does not exist yet.
        - fix to Data::Tabular::Extra::get() method. It now works
          correctly in an array context.

0.25 May 30, 2006
        - Added use of formulas for sum and average of rows and columns.
        - More general clean up.

0.24

0.23
        - Added more tests
        - General clean up
        - Added Build.PL

0.22

lib/Data/Tabular/Output/XLS.pm  view on Meta::CPAN

    for my $row ($self->rows()) {
        if ($row->is_title) {
	    if ($pin_title) {
	        next if $title_pinned;
		$title_pinned = 1;
	    }
	}
	for my $cell ($row->cells()) {
	    my ($y, $x) = ($cell->row_id, $cell->col_id);
	    my $data = $cell->data;
	    my $formula = '';
	    my $value = 'asdf';
	    eval {
		if (ref $data) {
		    $worksheet->write($y, $x, $data->string);
		} else {
		    $worksheet->write($y, $x, $data);
		}
	    };
	    if ($@) {
		die "$formula " . $@;
	    }
	}
    }
}

1;
__END__

=head1 NAME

lib/Data/Tabular/Output/XLS.pm  view on Meta::CPAN

	$cell_type .= '_hdr';
    }
    if ($row->type eq 'title') {
	$cell_type = $cell->title_format;
    } elsif ($row->type eq 'averages') {
	$type = 'text';
	$cell_type = 'averages_right';
    } elsif ($row->type eq 'header') {
    } elsif ($row->type eq 'totals') {
	if (ref($cell_data)) {
	    $type = 'formula';
	    $cell_type = $self->output->type($cell->name);
	}
    } else {
	$type = $self->output->type($cell->name);
    }
next unless $cell_data;
    my $format = undef;

    if (ref($cell_data)) {
# FIXME
	$type = 'formula';
    }

    if ($type eq 'date') {
	if ($cell_data) {
	    $worksheet->write_date_time($y, $x, $cell_data, $formats->{'date'});
	    $worksheet->set_column($x, $x, 20);
	}
    } elsif ($type eq 'time') {
	if ($cell_data) {
	    $worksheet->write_date_time($y, $x, $cell_data, $formats->{'time'});

lib/Data/Tabular/Output/XLS.pm  view on Meta::CPAN

	    $worksheet->write_number($y, $x, $cell_data, $formats->{$cell_type});
	}
    } elsif ($type eq 'text') {
	$worksheet->write_string($y, $x, $cell_data, $formats->{$cell_type});
    } elsif ($type eq 'dollar') {
	$worksheet->write_number($y, $x, $cell_data, $formats->{'dollar'});
    } elsif ($type eq 'number') {
	$worksheet->write_number($y, $x, $cell_data, $formats->{$cell_type});
    } elsif ($type eq 'percent') {
	$worksheet->write_number($y, $x, $cell_data, $formats->{$cell_type});
    } elsif ($type eq 'formula') {
	my $formula = '=';
	if ($cell_data->{type} eq 'sum') {
	    if (!defined $cell_data->{rows}) {
		$formula .= join('+', map({ my $x = $self->_get_col_id($_); chr(0x41+$x) . ($cell->row_id+1); } @{$cell_data->{columns}}));
	    } else {
		$formula .= join('+', map({ chr(0x41+$cell->col_id) . $_; } @{$cell_data->{rows}}));
	    }
	} elsif ($cell_data->{type} eq 'average' || $cell_data->{type} eq 'avg') {
	    $formula .= '(';
	    if (!defined $cell_data->{rows}) {
		$formula .= join('+', map({ my $x = $self->_get_col_id($_); chr(0x41+$x) . ($cell->row_id+1); } @{$cell_data->{columns}}));
	    } else {
		$formula .= join('+', map({ chr(0x41+$cell->col_id) . $_; } @{$cell_data->{rows}}));
	    }
	    $formula .= ')';
	    $formula .= "/" . scalar(@{$cell_data->{rows} || $cell_data->{columns}});
	} else {
	    warn $cell_data->{type};
	}

	$formula = '';
	$formula .= '';
	my $value = $cell_data->{html};

lib/Data/Tabular/Table/Group.pm  view on Meta::CPAN

}

sub column_sum
{
    my $self = shift;
    my $column_name = shift;
    my $ret;
    if ($ret = $self->{memo}->{$column_name}) {
        return $ret;
    }
    my $formula = '=SUM(';
    my $sum = 0;
    my @rows;
    for my $row ($self->raw_rows) {
        push(@rows, $row->id());
	my $next = $row->get($column_name);
	if (UNIVERSAL::isa($next, 'Data::Tabular::Formula')) {
die;
	    $next = $next->{html};
	}
	$sum += $next;

lib/Data/Tabular/Table/Group.pm  view on Meta::CPAN

}

sub column_average
{
    my $self = shift;
    my $column_name = shift;
    my $ret;
    if ($ret = $self->{memoa}->{$column_name}) {
        return $ret;
    }
    my $formula = '=SUM(';
    my $sum = 0;
    my @rows;
    my $count = 0;
    for my $row ($self->raw_rows) {
        push(@rows, $row->id());
	my $next = $row->get($column_name);
	if (UNIVERSAL::isa($next, 'Data::Tabular::Formula')) {
die;
	    $next = $next->{html};
	}



( run in 1.004 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )