- SEE ALSO
HTML::DataTable - Print HTML tables from Perl data
use HTML::DataTable my $list = HTML::DataTable->new( data => $cgi_data, columns => [ # hashrefs describing column formats ], rows => [ # arrayrefs listing data to show in table ], ); print $list;
Creates a new HTML::DataTable object.
The HTML color code for the background of the first row of the list.
If this is defined, there will be a 1px black line under the header.
If this is defined, then alternating rows will be colored differently.
The HTML color codes for the alternating backgrounds of the list rows.
If this evaluates to a reference to a subroutine, then that subroutine will be called with each row's values, and when the returned values changes, the table will be divided and the value printed as a section title. (Since there's no value initially, there will be a section title before the first row.)
If this is defined, the table header will be reprinted after each section title.
If this is defined, a linked alphabet index will be printed above the table header. Subclasses of this class are responsible for using the "letter" CGI parameter to show the appropriate rows.
If this is defined, then a field called "search" will be shown in the table header (after the alphabet, if that attribute is also defined). If it evaluates to a reference to a hash, then the keys of the hash will be shown in a SELECT control called "search_columns" after the field. Subclasses of this class are responsible for using these CGI parameters to show the appropriate rows.
Should be assigned a hashref representing the CGI parameters.
* An arrayref listing one arrayref holding the values to appear in each row of the list.
* An arrayref listing one hashref holding the values to appear in each row of the list.
* A hashref mapping each row's ID to a hashref holding the values to appear in that row of the list, in which case the "sort" attribute should name the hash key by which to sort the hashref entries.
An arrayref listing one hashref defining each column of the table. These hashrefs can have these attributes:
The text to print at the top of this column.
A second-level header to be printed above the column header; adjacent column's category headers will be merged if they are the same.
This can be either
* A scalar, which will be used as an index in the current row's data array
* An arrayref, which will list an index in the current row's data array and singular and plural nouns to append to the value found there
* A reference to a subroutine, which will be passed the current row's data array
* A hashref, which will map a predefined format name to an index in the current row's data array
A string to show if the value in that column is undefined. Defaults to "None".
style, class, align
If any of these attributes evaluate to a string, they will become the corresponding attributes of each table cell in the column.
The path or URL of a CGI program to which each entry will linked.
A reference to a hash listing the CGI parameters to be included in the "action" link. Each value is either a scalar or a reference, as for the "format" attribute.
If defined, then if the value in the column is undefined the "None" shown will be linked to the "action" URL.
If this is defined, then the column will be left blank if the value printed would be the same the that for the previous row.
If this is defined, then the column's content will be surrounded by <nobr> tags so it isn't formatted into multiple lines.
Returns the HTML that renders the list.
Returns the list as an Excel spreadsheet.
Nic Wolff <email@example.com> Jason Barden <firstname.lastname@example.org>