#! perl use strict; use warnings; use Test::More qw(no_plan); use Data::Report; my $out = ""; my $rep = Data::Report::->create (type => "html", layout => [ { name => "acct", title => "Acct", width => 6 }, { name => "desc", title => "Report", width => 40, align => "|" }, { name => "deb", title => "Debet", width => 10, align => "<" }, { name => "crd", title => "Credit", width => 10, align => ">" }, ], ); $rep->set_stylist( sub { my ($rep, $row, $col) = @_; return unless $col; return { class => "bar" } if $row && $row eq "_head" && $col && $col eq "deb"; return { class => "foo" } if $col eq "deb"; return; } ); $rep->set_output(\$out); $rep->start; $rep->add({ acct => "one", desc => "two", deb => "three", crd => "four" }); $rep->add({ acct => "one", desc => "two", deb => "three", crd => "four", _style => "xyz" }); $rep->finish; $rep->close; my $ref; { undef $/; $ref = } $ref =~ s/[\r\n]/\n/g; $out =~ s/[\r\n]/\n/g; is($out, $ref); __DATA__
Acct Report Debet Credit
one two three four
one two three four