<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"> my
$wb = Spreadsheet::WriteExcel->new('/opt/catalyst/dbms/lib/dbms/output/output.xls');</font>
<br><font size=2 face="sans-serif"> my
$ws = $wb->add_worksheet('Output');</font>
<br><font size=2 face="sans-serif"> my
$col = 0; my $row = 0;</font>
<br><font size=2 face="sans-serif"> 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">>This part works, I get my header
row.</font>
<br><font size=2 face="sans-serif"> foreach
my $field (@fields) {</font>
<br><font size=2 face="sans-serif">
$ws->write($row, $col, $field);</font>
<br>
<br><font size=2 face="sans-serif">
$col++;</font>
<br><font size=2 face="sans-serif"> }</font>
<br><font size=2 face="sans-serif"> $col=0;</font>
<br><font size=2 face="sans-serif"> $row++;</font>
<br><font size=2 face="sans-serif">>This doesn't, I get an error that
it can't locate the method, I tried "$ws->write($row, $col, $data->{$field)};"
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"> foreach
my $data ($sr->all) {</font>
<br><font size=2 face="sans-serif">
foreach my $field (@fields) {</font>
<br><font size=2 face="sans-serif">
$ws->write($row,
$col, $data->$field);</font>
<br>
<br><font size=2 face="sans-serif">
$col++;</font>
<br><font size=2 face="sans-serif">
} </font>
<br><font size=2 face="sans-serif">
$row++;</font>
<br><font size=2 face="sans-serif">
$col=0;</font>
<br><font size=2 face="sans-serif"> }</font>
<br>
<br><tt><font size=2>Len Jaffe <lenjaffe@jaffesystems.com> wrote
on 07/05/2012 12:59:15 PM:<br>
<br>
> From:</font></tt>
<br><tt><font size=2>> <br>
> Len Jaffe <lenjaffe@jaffesystems.com></font></tt>
<br><tt><font size=2>> <br>
> To:</font></tt>
<br><tt><font size=2>> <br>
> "DBIx::Class user and developer list" <dbix-class@lists.scsys.co.uk></font></tt>
<br><tt><font size=2>> <br>
> Date:</font></tt>
<br><tt><font size=2>> <br>
> 07/05/2012 01:03 PM</font></tt>
<br><tt><font size=2>> <br>
> Subject:</font></tt>
<br><tt><font size=2>> <br>
> Re: [Dbix-class] Problem getting data from resultset</font></tt>
<br><tt><font size=2>> <br>
> <br>
</font></tt>
<br><tt><font size=2>> On Thu, Jul 5, 2012 at 1:53 PM, Kenneth S Mclane
<ksmclane@us.ibm.com> wrote:</font></tt>
<br><tt><font size=2>> Yes, I can get the data that way, but I have
to specify each column <br>
> by name that way and I am trying to get this to be a bit more re-<br>
> usable. I need to be able to use this on many different pages, <br>
> supplying a function that doesn't need to be embedded and custom <br>
> hard coded for each query. I am looking to be able to first, grab
<br>
> the names of the columns so I can write the header row, then write
<br>
> the data, save the file and offer it up to the browser to be saved.
<br>
> I can't find a way to get a list of the field names from the result
<br>
> set, that would work as I could then store them in vars and then <br>
> loop through using the column names to get the values for each cell.
</font></tt>
<br><tt><font size=2>> <br>
> How are you specifying the names of the columns to the query?</font></tt>
<br><tt><font size=2>> <br>
> -- <br>
> lenjaffe@jaffesystems.com 614-404-4214
</font></tt><a href=www.volunteerable.net><tt><font size=2>www.volunteerable.net</font></tt></a>
<br><tt><font size=2>> 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>> Greenbar: Grubmaster: 2012-2009, Grub
Asst: 2008, Trained: 2007.</font></tt>
<br><tt><font size=2>> <br>
> _______________________________________________<br>
> 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>
> IRC: irc.perl.org#dbix-class<br>
> 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>
> 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>