HTML::QuickTable 1.12 review

Download
by rbytes.net on

HTML::QuickTable is a Perl module to quickly create fairly complex HTML tables. SYNOPSIS use HTML::QuickTable; my $q

License: Perl Artistic License
File size: 13K
Developer: Nathan Wiger
0 stars award from rbytes.net

HTML::QuickTable is a Perl module to quickly create fairly complex HTML tables.

SYNOPSIS

use HTML::QuickTable;

my $qt = HTML::QuickTable->new(
table_width => '95%', # opt method 1
td => {bgcolor => 'gray'}, # opt method 2
font_face => 'arial', # set font
font => {face => 'arial'}, # same thing
labels => 1, # make top ?
stylesheet => 1, # use stylesheet?
styleclass => 'mytable', # class to use
useid => 'results', # id="results_r1c2" etc
header => 0, # print header?
);

my $table1 = $qt->render(@array_of_data);

my $table2 = $qt->render(%hash_of_keys_and_values);

my $table3 = $qt->render($object_with_param_method);

This modules lets you easily create HTML tables. Like CGI::FormBuilder, this module does a lot of thinking for you. For a comprehensive module that gives you the ability to tweak every aspect of table building, see HTML::Table or Data::Table. This one gives you a lot of control, but is really designed as an easy way to expand arbitrary data structures.

The simplest table can be created with nothing more than:

my $qt = HTML::QuickTable->new;
print $qt->render(@data);

Where @data would be an array holding your data structure. For example, the data structure:

@data = (
[ 'nwiger', 'Nathan Wiger', 'x43264', 'nate@wiger.org' ],
[ 'jbobson', 'Jim Bobson', 'x92811', 'jim@bobson.com' ]
);

Would be rendered as something like:

< table >
< tr >< td >nwiger< /td >< td >Nathan Wiger< /td>< td >x43264< /td >< td >nate@wiger.org< /td >< /tr >
< tr >< td >jbobson< /td >< td >Jim Bobson< /td>< td >x92811< /td>< td >jim@bobson.com< /td >< /tr >
< /table >

Of course, the best use for this module is on dynamic data, say something like this:

use DBI;
use HTML::QuickTable;

my $qt = HTML::QuickTable->new(header => 1); # print header
my $dbh = DBI->connect( ... );

my $all_arrayref = $dbh->selectall_arrayref("select * from billing");

print $qt->render($all_arrayref);

With header => 1, you will get a brief CGI header as well as some basic HTML to prettify things. As such, the above will print out all the rows that your query selected in an HTML table.

Requirements:
Perl

HTML::QuickTable 1.12 keywords