note
kcott
<p>G'day [squarez],</p>
<p>Welcome to the monastery.</p>
<p>
I can't actually find a module called <c>WriteExcel</c> on [http://search.cpan.org/|CPAN]. There's a lot with <c>WriteExcel</c> in the name: I'm going to guess you're using [http://search.cpan.org/perldoc?Spreadsheet%3A%3AWriteExcel|Spreadsheet::WriteExcel].
</p>
<p>
This module has a method called [http://search.cpan.org/perldoc?Spreadsheet%3A%3AWriteExcel#write_row($row,_$column,_$array_ref,_$format)|write_row()] whose documentation has:
</p>
<blockquote><em>
"... This is useful for converting the results of a database query into an Excel worksheet. ..."
</em></blockquote>
<p>
You should be able to modify your code to something like (untested):
</p>
<code>
while (my @res = $sth->fetchrow_array()) {
@res = map { defined ? $_ : '' } @res;
$worksheet->write_row($i, 0, [@res]);
$i++;
}
</code>
<p>
I also noted [http://search.cpan.org/perldoc?Excel%3A%3AWriter%3A%3AXLSX|Excel::Writer::XLSX] has a method with the same name which appears to work the same (from a coding perspective).
</p>
<p>
Even if you're using a different module, you may still find the technique applicable. If not, let us know what you are using.
</p>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-861371">
<p>-- Ken</p>
</div></div>
996936
996936