<font size=2 face="sans-serif">I had it working earlier and went down
so many rabbit holes I lost track of what I had working. I came up with
the same solution as Rob just suggested to get my headers, and am using
that list to get the data, as soon as I remember the syntax I used.</font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; my
$wb = Spreadsheet::WriteExcel-&gt;new('/opt/catalyst/dbms/lib/dbms/output/output.xls');</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; my
$ws = $wb-&gt;add_worksheet('Output');</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; my
$col = 0; my $row = 0;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; my
@fields = qw/ department.department_code account_code account_name account_policy
compliance.percent_compliant metrics.num_servers metrics.num_subsystems
progress.percent_complete /;</font>
<br><font size=2 face="sans-serif">&gt;This part works, I get my header
row.</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; foreach
my $field (@fields) {</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; $ws-&gt;write($row, $col, $field);</font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; $col++;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; }</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; $col=0;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; $row++;</font>
<br><font size=2 face="sans-serif">&gt;This doesn't, I get an error that
it can't locate the method, I tried &quot;$ws-&gt;write($row, $col, $data-&gt;{$field)};&quot;
and I get no errors but no data. I also tried removing the arrow, but then
it thinks I have an undeclared hash.</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; foreach
my $data ($sr-&gt;all) {</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; foreach my $field (@fields) {</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $ws-&gt;write($row,
$col, $data-&gt;$field);</font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $col++;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; $row++;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; $col=0;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; }</font>
<br>
<br><tt><font size=2>Len Jaffe &lt;lenjaffe@jaffesystems.com&gt; wrote
on 07/05/2012 12:59:15 PM:<br>
<br>
&gt; From:</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; Len Jaffe &lt;lenjaffe@jaffesystems.com&gt;</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; To:</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; &quot;DBIx::Class user and developer list&quot; &lt;dbix-class@lists.scsys.co.uk&gt;</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; Date:</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; 07/05/2012 01:03 PM</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; Subject:</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; Re: [Dbix-class] Problem getting data from resultset</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; <br>
</font></tt>
<br><tt><font size=2>&gt; On Thu, Jul 5, 2012 at 1:53 PM, Kenneth S Mclane
&lt;ksmclane@us.ibm.com&gt; wrote:</font></tt>
<br><tt><font size=2>&gt; Yes, I can get the data that way, but I have
to specify each column <br>
&gt; by name that way and I am trying to get this to be a bit more re-<br>
&gt; usable. I need to be able to use this on many different pages, <br>
&gt; supplying a function that doesn't need to be embedded and custom <br>
&gt; hard coded for each query. I am looking to be able to first, grab
<br>
&gt; the names of the columns so I can write the header row, then write
<br>
&gt; the data, save the file and offer it up to the browser to be saved.
<br>
&gt; I can't find a way to get a list of the field names from the result
<br>
&gt; set, that would work as I could then store them in vars and then <br>
&gt; loop through using the column names to get the values for each cell.
</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; How are you&nbsp;specifying&nbsp;the names of the columns to the query?</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; -- <br>
&gt; lenjaffe@jaffesystems.com&nbsp;&nbsp; 614-404-4214 &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp;&nbsp;</font></tt><a href=www.volunteerable.net><tt><font size=2>www.volunteerable.net</font></tt></a>
<br><tt><font size=2>&gt; Proprietor: </font></tt><a href=http://www.theycomewithcheese.com/><tt><font size=2>http://www.theycomewithcheese.com/</font></tt></a><tt><font size=2>
- An Homage to Fromage</font></tt>
<br><tt><font size=2>&gt; Greenbar:&nbsp;Grubmaster:&nbsp;2012-2009, Grub
Asst: 2008, Trained: 2007.</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; _______________________________________________<br>
&gt; List: </font></tt><a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class"><tt><font size=2>http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class</font></tt></a><tt><font size=2><br>
&gt; IRC: irc.perl.org#dbix-class<br>
&gt; SVN: </font></tt><a href="http://dev.catalyst.perl.org/repos/bast/DBIx-Class/"><tt><font size=2>http://dev.catalyst.perl.org/repos/bast/DBIx-Class/</font></tt></a><tt><font size=2><br>
&gt; Searchable Archive: </font></tt><a href="http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk"><tt><font size=2>http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk</font></tt></a>