Hi Monks!
I am trying to read a .XLS file to extract the data from its column and later insert them into a database, but the code is giving me a lot of uninitialized value messages. I just cant see where in the code it could be happening and why, here is the code, unless there is a better way of doing this!
#!/usr/bin/perl -w use strict; use warnings; use Spreadsheet::ParseExcel; my $file = "../my_file.xls"; use vars qw($user_name $user_number $identification); my $workbook = Spreadsheet::ParseExcel::Workbook->Parse($file)or die " +Unable to open $file\n"; foreach my $page (@{$workbook->{Worksheet}}) { print "Page $page\n"; foreach my $col ($page->{MinCol} .. $page->{MaxCol}) { if ($page->{Cells}[0][$col]->{Val} eq "User Name") { $user_name = $col; print "$user_name\n"; } if ($page->{Cells}[0][$col]->{Val} eq "User Number") { $user_number = $col; print "$user_number\n"; } if ($page->{Cells}[0][$col]->{Val} eq "Identification") { $identification = $col; print "$identification\n"; } } foreach my $row ($page->{MinRow}+1 .. $page->{MaxRow}) { my $got_user_name = $page->{Cells}[$row][$user_name]->{Val}; my $got_user_number = $page->{Cells}[$row][$user_number]->{Val}; my $got_identification = $page->{Cells}[$row][$identification]->{V +al}; print "\n$got_user_name\n$got_user_number\n$got_identification\n"; } } exit;


Thanks for looking!

In reply to Parsing XLS file Help! by Anonymous Monk

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.