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

In reply to Spreadsheet::XLS chokes on CGI uploads by tbodine88

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.