- Perl 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| dist | ||
| lib/Data/Flex | ||
| LICENSE | ||
| Makefile.PL | ||
| MANIFEST | ||
| MANIFEST.SKIP | ||
| README.md | ||
NAME
Data::Flex::Report - Generic report table generation
VERSION
version 1.16
SYNOPSIS
An example of use might be
use Data::Flex::Report;
my $report = Data::Flex::Report->new;
$report->add_headers( 'Item Description', 'Quantity', 'Price' );
$report->add_rows( [ 'Widgets, square 4mm', '16', '4.99' ],
[ 'Thingamajigs folded to fit', '3', '12.49' ],
);
print $report->as_text;
print $report->as_html;
print $report->as_json;
Additionally, alignment can be given for columns as part of the headers.
$report->add_headers( { 'value' => 'Item Description', 'align' => 'L' },
{ 'value' => 'Quantity', 'align' => 'N' },
{ 'value' => 'Price', 'align' => 'N' },
);
The alignment values are L, R, C & N. The last signifying a numeric right-aligned value.
Additionally, when headers are defined by a hash they can take a name value which can be used if the rows added are themselves hashes.
SYNOPSIS
Data::Flex::Report provides an object to hold details of a tabular report
consisting of a title, headers, rows and footnotes.
It provides methods which will output the report as text, html and json.
INITIALISATION METHODS
-
new
my $report = Data::Flex::Report->new;
Methods
-
title
$report->title( 'This is the report title' );Get/set the report title.
-
timestamped_title
$report->timestamped_title( 'This is the report title' );Set the report title with a standard minute-resolution time stamp suffix.
print $report->title; C<This is the report title - 2020-11-08 12:27> -
stacked
$report->stacked( 1 );Get/set whether the report is stacked rows.
-
add_headers
$report->add_headers( 'Item Description', 'Quantity', 'Price' );Additionally, alignment can be given for columns as part of the headers.
$report->add_headers( { 'value' => 'Item Description', 'align' => 'L' }, { 'value' => 'Quantity', 'align' => 'N' }, { 'value' => 'Price', 'align' => 'N' }, );The alignment values are L, R, C & N. The last signifying a numeric right-aligned value.
Additionally, when headers are defined by a hash they can take a name value which can be used if the rows added are themselves hashes.
The method converts either of the two input formats into a list of
Data::Flex::Report::Headerobjects and can also take previously created instances. -
add_rows
$report->add_rows( [ 'Widgets, square 4mm', '16', '4.99' ], [ 'Thingamajigs folded to fit', '3', '12.49' ], ); -
add_footnotes
$report->add_footnotes( "The above details are subject to change without notice" ); -
row_count
print "Total number of rows = ", $report->row_count, "\n; -
as_text
Returns the report output in plain text, with columns aligned per header definitions. Assumes a monospace font for alignment.
-
as_html
Returns the report output in HTML format.
-
as_json
Returns the report output in JSON format.
-
as
Takes a single text parameter from the set textB, html, json.
Returns the report output in the specified format.
-
get_as_types
Returns the list of report output types to allow validation, display etc.
Returns either an array or array reference depending on called context.
COMPATIBILITY
Data::Flex::ReportrequiresClass::Accessorize,Data::Dumper,HTML::Entities,MIME::Parser&JSON.
AUTHOR
Bernard Quatermass toolsmith@quatermass.co.uk
COPYRIGHT AND LICENSE
This software is copyright (c) 2020,2021 by Bernard Quatermass.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.