Sample data:foreach my $row (@data) { push @{$hash{$row->[0]}}, { companyid => $row->[1], apptype => $row->[2], state => $row->[3], count => $row->[4], }; }
My first stab at building the params, not even close to working:%hash = ( 'One' => [ { 'apptype' => 'xxx', 'count' => '123', 'companyid' => 'xxx', 'state' => 'xx' }, { 'apptype' => 'xxx', 'count' => '123', 'companyid' => 'xxx', 'state' => 'xx' }, { 'apptype' => 'xxx', 'count' => '123', 'companyid' => 'xxx', 'state' => 'xx' } ], 'Two' => [ { 'apptype' => 'xxx', 'count' => '123', 'companyid' => 'xxx', 'state' => 'xx' }, ] );
And the XML to build the worksheet:foreach my $rep (sort keys %hash) { $template->param( REP => { rep => $rep, DATA => $hash{$rep} }, ); }
<workbook> <loop name="REP"> <worksheet name="$rep"> <row> <cell text="QM Distribution" /> </row> <row> </row> <row> <cell text="Comp_Recid" /> <cell text="ApplicationType" /> <cell text="State" /> <cell text="Count (*)" /> </row> <loop name="DATA"> <row> <cell text="$companyid" /> <cell text="$apptype" /> <cell text="$state" /> <cell text="$count" /> </row> </loop> </worksheet> </loop> </workbook>
In reply to Excel::Template and a hash of arrays of hashes by kwaping
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |