kwaping has asked for the wisdom of the Perl Monks concerning the following question:
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>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Excel::Template and a hash of arrays of hashes
by wfsp (Abbot) on Dec 29, 2006 at 17:11 UTC | |
by kwaping (Priest) on Dec 29, 2006 at 17:18 UTC |