CPAN-Testers-WWW-Statistics-Excel

 view release on metacpan or  search on metacpan

lib/CPAN/Testers/WWW/Statistics/Excel.pm  view on Meta::CPAN

package CPAN::Testers::WWW::Statistics::Excel;

use warnings;
use strict;
use vars qw($VERSION);

$VERSION = '0.06';

#----------------------------------------------------------------------------

=head1 NAME

CPAN::Testers::WWW::Statistics::Excel - CPAN Testers Statistics Excel tool.

=head1 SYNOPSIS

  my %hash = { logfile => 'my.log' };
  my $ct = CPAN::Testers::WWW::Statistics::Excel->new(%hash);
  $ct->create( source => $source, target => $target );

=head1 DESCRIPTION

Using previously formatted data, generate Excel format files.

=cut

# -------------------------------------
# Library Modules

use base qw(Class::Accessor::Fast);

use File::Basename;
use File::Path;
use HTML::Entities;
use HTML::TokeParser;
use IO::File;
use Spreadsheet::WriteExcel;

# -------------------------------------
# Variables

my %format_config = (
    head    => { border => 1, pattern => 1, color => 'black',   bg_color => 'gray',     bold => 1 },
    lots    => { border => 1, pattern => 1, color => 'black',   bg_color => 'green',    align => 'right' },
    more    => { border => 1, pattern => 1, color => 'black',   bg_color => 'lime',     align => 'right' },
    some    => { border => 1, pattern => 1, color => 'black',   bg_color => 'yellow',   align => 'right' },
    none    => { border => 1, pattern => 1, color => 'black',   bg_color => 'silver',   align => 'center', valign => 'middle' },
    totals  => { border => 1, pattern => 1, color => 'white',   bg_color => 'black',    bold => 1 },
);

# -------------------------------------
# Subroutines

=head1 INTERFACE

=head2 The Constructor

=over 4

=item * new

Object constructor. Takes an optional hash, which can contain initial settings
for log file creation:

  logfile   - path to log file
  logclean  - append (0) or overwrite/create (1)

=back

=cut

sub new {
    my $class = shift;
    my %hash  = @_;

    my $self = {};
    bless $self, $class;

    $self->logfile(  $hash{logfile}  || '' );
    $self->logclean( $hash{logclean} || 0 );

    $self->_log("logfile  =" . $self->logfile  );
    $self->_log("logclean =" . $self->logclean );

    return $self;
}

=head2 Methods

=over 4

=item * create

Method to facilitate the creation of an Excel file.

Parameter values are contained within a hash to the method:

  source    - path to source HTML containing table
  target    - path to target Excel format file

In addition the following hash values can also be passed:

  title     - title for the file (Excel property)
  author    - author of the file (Excel property)
  comments  - comments string    (Excel property)

=item * logfile



( run in 2.660 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )