X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Freport_tax-xls.cgi;fp=httemplate%2Fsearch%2Freport_tax-xls.cgi;h=54a17d0b644680fc3d9247580e522012d018a323;hb=11686f7c21bed96f563e70212f44044604f8a733;hp=0000000000000000000000000000000000000000;hpb=e139c51505a0455bbc7a0aeced97e6cc9012e25c;p=freeside.git diff --git a/httemplate/search/report_tax-xls.cgi b/httemplate/search/report_tax-xls.cgi new file mode 100755 index 000000000..54a17d0b6 --- /dev/null +++ b/httemplate/search/report_tax-xls.cgi @@ -0,0 +1,158 @@ +<% $data %> +<%init> + +use Spreadsheet::WriteExcel; +use Spreadsheet::WriteExcel::Utility 'xl_range_formula'; +use List::Util 'max'; +use HTML::TableExtract 'tree'; + +my $data = ''; +my $XLS = new IO::Scalar \$data; +my $workbook = Spreadsheet::WriteExcel->new($XLS) + or die "Error opening .xls file: $!"; + +# hardcoded formats, this could be handled better +my $light_gray = $workbook->set_custom_color(63, '#eeeeee'); +my %format = ( + title => { + size => 24, + align => 'center', + bg_color => 'silver', + }, + colhead => { + size => 11, + bold => 1, + align => 'center', + valign => 'vcenter', + text_wrap => 1, + }, + rowhead => { + size => 11, + valign => 'bottom', + text_wrap => 1, + }, + amount => { + size => 11, + align => 'right', + valign => 'bottom', + num_format=> 8, + }, + 'size-1' => { + size => 7.5, + align => 'center', + valign => 'vcenter', + bold => 1, + text_wrap => 1, + }, + 'size+1' => { + size => 12, + align => 'center', + valign => 'vcenter', + bold => 1, + }, + text => { + size => 11, + text_wrap => 1, + }, +); +my %default = ( + font => 'Calibri', + bg_color => $light_gray, + border => 1, +); +my @widths = ( #ick + 18, (10.5, 3) x 6, 10.5, 10.5, 3, 10.5, 3, 10.5, 3, 10.5 +); +foreach (keys(%format)) { + my %f = (%default, %{$format{$_}}); + $format{$_} = $workbook->add_format(%f); + $format{"m_$_"} = $workbook->add_format(%f); # for merged cells + $format{"t_$_"} = $workbook->add_format(%f, bg_color => 'yellow'); # totals +} +my $ws = $workbook->add_worksheet('taxreport'); + +my $htmldoc = include('report_tax.cgi'); + +my ($title) = ($htmldoc =~ /