I am trying to use Excel::Template (hi dragonchild!) to create an Excel workbook. Each worksheet should be titled with the name of a sales rep, and on that page should be four columns of data. Here's the relevant code.
Building the hash:
foreach my $row (@data) { push @{$hash{$row->[0]}}, { companyid => $row->[1], apptype => $row->[2], state => $row->[3], count => $row->[4], }; }
Sample data:
%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' }, ] );
My first stab at building the params, not even close to working:
foreach my $rep (sort keys %hash) { $template->param( REP => { rep => $rep, DATA => $hash{$rep} }, ); }
And the XML to build the worksheet:
<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>
Any suggestions to help me get this working are appreciated!

Update: fixed some obviously bad syntax in the param code.

---
It's all fine and dandy until someone has to look at the code.

In reply to Excel::Template and a hash of arrays of hashes by kwaping

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.