I was playing with writing a spreadsheet to the screen, and this code works:
#!/usr/local/bin/perl
use strict;
use warnings;
use CGI qw/:standard/;
if( param())
{
print header(-type=>'application/vnd.ms-excel',
-attachment=>'test.xls');
use Spreadsheet::WriteExcel;
my $workbook = Spreadsheet::WriteExcel->new('-');
my $worksheet = $workbook->addworksheet(param('color'));
$worksheet->write(0,0,param('name'));
$worksheet->write(0,1,"dere");
$worksheet->write(0,2,"be jammin");
$worksheet->write(1,0,"Monkey");
$worksheet->write(2,0,param('words'));
$workbook->close();
} else {
print header,
start_html('A Simple Example'),
h1('A Simple Example'),
start_form,
"What's your name? ",textfield('name'),p,
"What's the combination?", p,
checkbox_group(-name=>'words',
-values=>['eenie','meenie','minie','moe'],
-defaults=>['eenie','minie']), p,
"What's your favorite color? ",
popup_menu(-name=>'color',
-values=>['red','green','blue','chartreuse']),p,
submit,
end_form,
hr;
}
Hope this helps!
Update: The above code was pretty much cut'n'pasted from cgi
|