http_header('Content-Type' => 'text/plain' );
my $csv = new Text::CSV_XS { 'always_quote' => 1,
- #'eol' => "\015\012", #"\012"
+ 'eol' => "\n", #"\015\012", #"\012"
};
$csv->combine(@$header); #or die $csv->status;
# }
#}
if ( ref($field) eq 'CODE' ) {
- $worksheet->write($r, $c++, &{$field}($row) );
+ foreach my $value ( &{$field}($row) ) {
+ $worksheet->write($r, $c++, $value );
+ }
} else {
$worksheet->write($r, $c++, $row->$field() );
}
} else {
( my $xlsname = $opt{'name'} ) =~ s/\W//g;
$opt{'name'} =~ s/s$// if $total == 1;
+
+ my @menubar = ();
+ if ( $opt{'menubar'} ) {
+ @menubar = @{ $opt{'menubar'} };
+ } else {
+ @menubar = ( 'Main menu' => $p );
+ }
%>
<%= include( '/elements/header.html', $opt{'title'},
- include( '/elements/menubar.html', 'Main menu' => $p )
+ include( '/elements/menubar.html', @menubar )
)
%>
+ <%= defined($opt{'html_init'}) ? $opt{'html_init'} : '' %>
<% my $pager = include ( '/elements/pager.html',
'offset' => $offset,
'num_rows' => scalar(@$rows),
<TABLE>
<TR>
- <TD>
+ <TD VALIGN="bottom">
<%= $total %> total <%= $opt{'name'} %><BR>
<% if ( $opt{'count_addl'} ) { %>
<% my $n=0; foreach my $count ( @{$opt{'count_addl'}} ) { %>
<%= $pager %>
<STYLE TYPE="text/css">
.grid table { border: solid; empty-cells: show }
- .grid TH { padding-left: 1px; padding-right: 1px; border: 1px solid #dddddd; border-bottom: dashed 1px black; border-right: none }
- .grid TD { padding-left: 1px; padding-right: 1px; empty-cells: show; border: 1px solid #cccccc; border-bottom: none; border-right: none }
+ .grid TH { padding-left: 3px; padding-right: 3px; border: 1px solid #dddddd; border-bottom: dashed 1px black; border-right: none }
+ .grid TD { padding-left: 3px; padding-right: 3px; empty-cells: show; border: 1px solid #cccccc; border-bottom: none; border-right: none }
</STYLE>
<TABLE CLASS="grid" CELLSPACING=0 CELLPADDING=0 BORDER=1 BORDERCOLOR="#000000" STYLE="border: solid 1px black; empty-cells: show">
<TR>
%>
<TR>
<% if ( $opt{'fields'} ) {
- my $links = $opt{'links'} ? [ @{$opt{'links'}} ] : '';
+
+ my $links = $opt{'links'} ? [ @{$opt{'links'}} ] : '';
my $aligns = $opt{'align'} ? [ @{$opt{'align'}} ] : '';
- foreach my $field ( @{$opt{'fields'}} ) {
+ my $colors = $opt{'color'} ? [ @{$opt{'color'}} ] : [];
+ my $sizes = $opt{'size'} ? [ @{$opt{'size'}} ] : [];
+ my $styles = $opt{'style'} ? [ @{$opt{'style'}} ] : [];
+
+ foreach my $field (
+
+ map {
+ if ( ref($_) eq 'CODE' ) {
+ &{$_}($row);
+ } else {
+ $row->$_();
+ }
+ }
+ @{$opt{'fields'}}
+
+ ) {
+
my $align = $aligns ? shift @$aligns : '';
$align = " ALIGN=$align" if $align;
+
my $a = '';
if ( $links ) {
my $link = shift @$links;
$a = qq(<A HREF="$a">);
}
}
+
+ my $font = '';
+ my $color = shift @$colors;
+ $color = &{$color}($row) if ref($color) eq 'CODE';
+ my $size = shift @$sizes;
+ $size = &{$size}($row) if ref($size) eq 'CODE';
+ if ( $color || $size ) {
+ $font = '<FONT '.
+ ( $color ? "COLOR=#$color " : '' ).
+ ( $size ? qq(SIZE="$size" ) : '' ).
+ '>';
+ }
+
+ my($s, $es) = ( '', '' );
+ my $style = shift @$styles;
+ $style = &{$style}($row) if ref($style) eq 'CODE';
+ if ( $style ) {
+ $s = join( '', map "<$_>", split('', $style) );
+ $es = join( '', map "</$_>", split('', $style) );
+ }
+
%>
- <% if ( ref($field) eq 'CODE' ) { %>
- <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"<%= $align %>><%= $a %><%= &{$field}($row) %><%= $a ? '</A>' : '' %></TD>
- <% } else { %>
- <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"<%= $align %>><%= $a %><%= $row->$field() %><%= $a ? '</A>' : '' %></TD>
- <% } %>
+ <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"<%= $align %>><%= $font %><%= $a %><%= $s %><%= $field %><%= $es %><%= $a ? '</A>' : '' %><%= $font ? '</FONT>' : '' %></TD>
<% } %>
<% } else { %>
<% foreach ( @$row ) { %>
<% } %>
</TR>
<% } %>
+
+ <% if ( $opt{'footer'} ) { %>
+ <TR>
+ <% foreach my $footer ( @{ $opt{'footer'} } ) { %>
+ <TD CLASS="grid" BGCOLOR="#dddddd" STYLE="border-top: dashed 1px black;"><i><%= $footer %></i></TH>
+ <% } %>
+ </TR>
+ <% } %>
</TABLE>
<%= $pager %>