Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Error while reading .xls file

by a.alandkar (Novice)
on Aug 29, 2014 at 18:01 UTC ( [id://1099028]=note: print w/replies, xml ) Need Help??


in reply to Re: Error while reading .xls file
in thread Error while reading .xls file

Thank you mate. It works. :)

Replies are listed 'Best First'.
Re^3: Error while reading .xls file
by AppleFritter (Vicar) on Aug 29, 2014 at 18:45 UTC
    You're welcome! *tips hat*

      Hi, is it necessary to close the file after reading it too..? i have updated the code,i.e. added some function and finding the same error when i run it. I have added following function

      &extract_data(); sub extract_data() { my $parsedata = Spreadsheet::ParseExcel->new(); my $workbook_data = $parsedata->parse('test.xls'); for my $worksheet1 ( $workbook_data->worksheet(0) ) { for my $col ($col_min .. $col_max) { my $cell = $worksheet1->get_cell( 0, $col ); if($p_name eq $cell) { print("Done"); } } } }

      when i run the code it give me (

      Can't call method "worksheet" on an undefined value at D:\Perl\Xls_han +dling.pl line 110, <STDIN> line 6.
      ) error. And if i try to close parser i.e. $parser -> close() it says (
      Can't call method "worksheet" on an undefined value at D:\Perl\Xls_han +dling.pl line 110, <STDIN> line 6.
      )

        Hi, is it necessary to close the file after reading it too..?

        Have you tried it, to see if it makes a difference? You're also still not using error checking, as the module's documentation strongly recommends you do and as I suggested in my reply above. Please do so!

        On a side note, could you use <code> or <tt> tags for the error messages? It'll make your post much more readable to future readers. Thanks!

        Hi, I assume line 110 of your script is
        for my $worksheet1 ( $workbook_data->worksheet(0) )
        and the error message tells you that $workbook_data is undefined at that point. Which in turn means that
        my $workbook_data = $parsedata->parse('test.xls');

        did encounter some problem...

        AppleFritter already told you how to find this out.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1099028]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (2)
As of 2024-04-19 19:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found