NAME

WWW::Analytics::MultiTouch::Tabular - Provides various output formats for writing tabular reports

SYNOPSIS

use WWW::Analytics::MultiTouch::Tabular;

my @reports = (
    { 
    title => "My Title",
    sheetname => "My Sheet Name",
    headers => [ "Column1", "Column2", "Column3" ],
    data => \@data,
    },
    ...
    );
my $output = WWW::Analytics::MultiTouch::Tabular->new({'format' => 'txt', outfile => $file});
$output->print(\@reports);
$output->close();

DESCRIPTION

Takes a list of reports and outputs them in the specified format (text, csv, or Excel).

METHODS

new

$output = WWW::Analytics::MultiTouch::Tabular->new({format => 'txt', outfile => $file});

OPTIONS

format

txt, csv or xls.

outfile

Name of output file

print

$output->print(\@reports);

Prints given data in txt, csv, or xls format.

Each item in @reports is a hash containing the following elements:

title

Report title

sheetname

Sheet name, where applicable (as in spreadsheet output).

headers

Column headers

data

Array of data; each row is a row in the output, with columns corresponding to the column headers given.

txt

$output->txt(\@reports);

Generate output in plain text format.

csv

$output->csv(\@reports);

Generate output in CSV format.

xls

$output->xls(\@reports);

Generate output in Excel spreadsheet format.

open

format

outfile

filehandle

$tab->format('csv');
$tab->outfile("$dir/csv-test.csv");
$tab->open;

$tab->open("xls", "$dir/xls-test.xls");

$tab->filehandle(\*STDOUT);

'open' opens a file for writing. It is usually not necessary to call 'open' as it is implicit in 'new'. However, if you wish to re-use the object created with 'new' to output a different format or to a different file, then you need to call open with the new format/file arguments, or after setting the new format and output file with the format and outfile methods.

If no outfile is provided as an argument or previously set, STDOUT will be used.

As an alternative to 'open', you can set the file handle explicitly using $tab->filehandle().

close

Close file

SEE ALSO

Data::Tabular and Data::Tabular::Dumper do a similar thing, but gave me various issues around encoding and correctly producing output.

AUTHOR

Jon Schutz, <jon at jschutz.net>

BUGS

Please report any bugs or feature requests to bug-www-analytics-multitouch at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-Analytics-MultiTouch. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc WWW::Analytics::MultiTouch

You can also look for information at:

COPYRIGHT & LICENSE

Copyright 2010 YourAmigo Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.