tbodine88 has asked for the wisdom of the Perl Monks concerning the following question:
OK so I wrote a cgi page that up loads an excel xls spread sheet, to convert to html, but when I call Spreadsheet::XLSX -> new ($fh,$converter) I always get the Cannot open data as Zip archive at Spreadsheet/XLSX.pm line 28
However if I ftp the file to the linux server then open it with Spreadsheet::XLSX -> new ($file, $converter), it works fine. Why?
First the web code:
my $converter = Text::Iconv->new("utf-8","windows-1251"); if ( !$excelFile ){ die "Need a file name to upload"; } # end if no file name open($fh, "+>", undef) or die "Failed to write tempFile \n"; binmode($fh); while ($bytesread = read($excelFile, $buffer, $num_bytes)) { print $fh $buffer; } # end while seek($fh,0,0); my $excel = Spreadsheet::XLSX -> new ($fh,$converter); #(convert to html here)
Now the command line version
I also tried uploading and copying to a file, then using its name as an argument to "Spreadsheet::XLSX -> new" Any ideas would be appreciated. Thanks & Regards Tom Bodinemy $file = shift @ARGV; my $converter = Text::Iconv->new("utf-8","windows-1251"); my $excel = Spreadsheet::XLSX -> new ($file, $converter); die "open failed" unless $excel; #(convert to html here)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Spreadsheet::XLS chokes on CGI uploads
by kcott (Archbishop) on May 06, 2014 at 20:33 UTC | |
Re: Spreadsheet::XLS chokes on CGI uploads
by graff (Chancellor) on May 07, 2014 at 03:08 UTC | |
Re: Spreadsheet::XLS chokes on CGI uploads
by Tux (Canon) on May 07, 2014 at 09:13 UTC |
Back to
Seekers of Perl Wisdom