As above, check your (implicit open) in line 3.

Nonetheless, your script (with its numerous problems intact) reads the spreadsheet au.xls (when that's in same dir with the script and presumably, when au.xls actually exists where you say it does.

au.xls, in same dir with script:
captionColA captionColB captionColC http://abc.com 3 abc http://www.xyz.com 4 xyz foo.bar 5 fb
and, changing your test in line 12 to if ($row > 0) { (still not the right way to do this, but workable), execution looks like this:

pl_test>perl 827414.pl http://abc.com http://www.xyz.com foo.bar Use of uninitialized value in foreach loop entry at 827414.pl line 12. Use of uninitialized value in foreach loop entry at 827414.pl line 12. Argument "" isn't numeric in numeric gt (>) at 827414.pl line 14. Use of uninitialized value in foreach loop entry at 827414.pl line 12. Use of uninitialized value in foreach loop entry at 827414.pl line 12. Argument "" isn't numeric in numeric gt (>) at 827414.pl line 14. pl_test>

And the minimally-modified (ie, largely uncorrected) script:

#!/usr/bin/perl use strict; use warnings; # id: 827414 use Spreadsheet::ParseExcel; my $excel = Spreadsheet::ParseExcel::Workbook->Parse("au.xls"); my $excel_file_url; #start looping the Excel sheet for my $sheet (@{$excel->{Worksheet}}) { $sheet->{MaxRow} ||= $sheet->{MinRow}; for my $row ($sheet->{MinRow} .. $sheet->{MaxRow}) { #looping for each row if ($row > 0) { #get the file url path from excel sheet at corresponding +row, col 0 my $cell_value=$sheet->{Cells}[$row][0]; $excel_file_url=$cell_value->{Val}; print $excel_file_url . " \n"; } } }

HTH.


In reply to Re: parsing excel sheet from a perl program by ww
in thread parsing excel sheet from a perl program by rahulgsp83

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.