You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Jim Martinez <jj...@bigbigorg.org> on 2002/02/01 17:57:09 UTC
perl module
Hi,
I'm having trouble with a perl cgi script and I think it's because of the
way I built apache.
The cgi script (included below) is a sample cgi from the
Spreadsheet::WriteExcel perl module. The script runs fine from the
command line (meaning the excel file it creates if fine), but when I run
it through apache, I get an excel file of size 0. The script also runs
fine under apache from another machine.
A google search suggesting this may be a problem with the way perl uses
STDOUT.
A log search provides no additional help, there are no errors.
Any ideas?
I'm running apache 1.3.22, mod_perl 1.26, perl 5.6.1 on a linux
2.4.16.
Best regards,
Jim Martinez
#!/usr/bin/perl -w
$|++;
###############################################################################
#
# Example of how to use the Spreadsheet::WriteExcel module to send an
Excel
# file to a browser in a CGI program.
#
# On Windows the hash-bang line should be something like:
# #!C:\Perl\bin\perl.exe
#
# reverse('©'), March 2001, John McNamara, jmcnamara@cpan.org
#
use strict;
use Spreadsheet::WriteExcel;
# Set the filename and send the content type
my $filename ="cgitest.xls";
#print "Content-type: application/vnd.ms-excel\n";
# The Content-Disposition will generate a prompt to save the file. If you
want
# to stream the file to the browser, comment out the following line.
#print "Content-disposition: attachment;filename=$filename\n";
print "Content-type: application/vnd.ms-excel\n";
print "Content-disposition: attachment;filename=$filename\n";
print "\n";
# Create a new workbook and add a worksheet. The special Perl filehandle -
will
# redirect the output to STDOUT
#
my $workbook = Spreadsheet::WriteExcel->new("-");
my $worksheet = $workbook->addworksheet();
# Set the column width for column 1
$worksheet->set_column(0, 0, 20);
# Create a format
my $format = $workbook->addformat();
$format->set_bold();
$format->set_size(15);
$format->set_color('blue');
# Write to the workbook
$worksheet->write(0, 0, "Hi Excel!", $format);
$workbook->close();
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org