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
my $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)
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 Bodine
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.