On Fri, Jun 25, 2010 at 1:30 PM, Ludwig Isaac Lim <[email protected]> wrote:
> Hi:
>
> I'm writing a CGI application in PERL running on HP-UX that needs to export
> its query results to an Excel file.
>
> My alternatives are :
> a) export it using perl module Text::CSV, but the set the CGI headers to
> Excel via print header(-type => 'application/vnd.ms-excel');
> b) Use Spreadsheet::WriteExcel to generate excel binary files.
Another solution, which is quite similar to (a), is to generate
tab-delimited text file and name it with a .xls extension. You just
have to make sure that there's no tab charater inside your data or
just use a different delimiter. This will only work though on systems
where .xls is associated to a spreadsheet application.
Regarding Text::CSV, I've never used it to create a CSV file. I find
simpler to just do:
my @array = ('foo', 'bar', 'Escape "quote mark" with two "quote
marks"', 'baz');
print join ',', map { s/"/""/g; qq/"$_"/ } @array;
HTH
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
http://lists.linux.org.ph/mailman/listinfo/plug
Searchable Archives: http://archives.free.net.ph