Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Module location and Setup Error Message.

by Anonymous Monk
on Apr 19, 2018 at 11:46 UTC ( #1213162=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm Trying to read xls and xlsx files . As far as I'm aware I have downloaded and installed all the correct modules. However when I run The Code I encounter this error message. (BELOW)

I'm strugging to breakdown and understand the message as to what perl is telling me. Any help or suggestions would be gratefully received and appreciated

Can't locate Spreadsheet/ParseExcel/Simple.pm in @INC (@INC contains: +C:/Strawberry/perl/site/lib/MSWin32-x86-multi-thread C:/Strawberry/pe +rl/site/lib C:/Strawberry/perl/vendor/lib C:/Strawberry/perl/lib .) a +t C:\perl_tests\readxls.PL line 6. BEGIN failed--compilation aborted at C:\perl_tests\readxls.PL line 6. Press any key to continue . . .
My Pl file is below
#!/usr/bin/env perl use strict; use warnings; use Spreadsheet::ParseExcel::Simple qw(); my $xls = Spreadsheet::ParseExcel::Simple->read("To_read.xls"); foreach my $sheet ($xls->sheets) { while ($sheet->has_data) { my @data = $sheet->next_row; print join "|", @data; print "\n"; } }

Replies are listed 'Best First'.
Re: Module location and Setup Error Message.
by marto (Archbishop) on Apr 19, 2018 at 11:48 UTC

    It'd help if you told us how you downloaded and installed these modules, post formatting also makes things easier to read (How do I post a question effectively?). Since you're using Strawberry perl, why not use cpanm to do all this for you?

    cpanm Module::Name

    This also installs module dependencies.

      After trying to install the module cpanm is giving me the following messages

      C:\Strawberry\Spreadsheet-Simple-1.0.0>cpan module::Spreadsheet-Simple +-1.0.0 CPAN: LWP::UserAgent loaded ok (v6.02) CPAN: Time::HiRes loaded ok (v1.9721) Fetching with LWP: http://cpan.strawberryperl.com/authors/01mailrc.txt.gz CPAN: YAML loaded ok (v0.73) CPAN: CPAN::SQLite loaded ok (v0.199) Fetching with LWP: http://cpan.strawberryperl.com/modules/02packages.details.txt.gz Fetching with LWP: http://cpan.strawberryperl.com/modules/03modlist.data.gz Database was generated on Fri, 20 Apr 2018 18:15:04 GMT Updating database file ... Gathering information from index files ... Obtaining current state of database ... Populating database tables ... Done! Warning: Cannot install module::Spreadsheet-Simple-1.0.0, don't know w +hat it is. Try the command i /module::Spreadsheet-Simple-1.0.0/ to find objects with matching identifiers.

      Thanks for your suggestions on using cpanm to install but it's not allowing me to install for some reason

      Any further suggestions would be really helpful

      Please find below the style and expected output I would like , Although Not identical to the information contained within my xlxs /xls file it's the what i'm requiring

      \ [ [0] { error undef, parser "Spreadsheet::XLSX", sheet { Sheet1 1 }, sheets 1, type "xlsx", version 0.13 }, [1] { attr [], B1 "Income Statement 2014", B2 "Revenue", B3 "Cost of goods sold", B4 "Gross profit", B5 "Financing costs", B6 "Tax", B7 "Net profit", cell [ [0] [], [1] [], [2] [ [0] undef, [1] "Income Statement 2014", [2] "Revenue", [3] "Cost of goods sold", [4] "Gross profit", [5] "Financing costs", [6] "Tax", [7] "Net profit" ], [3] [ [0] undef, [1] undef, [2] 50000, [3] 2500, [4] 47500, [5] 7150, [6] 10087.5, [7] 30262.5 ] ], C2 " $ 50,000.00 ", C3 " $ 2,500.00 ", C4 " $ 47,500.00 ", C5 " $ 7,150.00 ", C6 " $ 10,087.50 ", C7 " $ 30,262.50 ", label "Sheet1", maxcol 3, maxrow 7 } ] This shows that $workbook is an arrayref, whose first element describe +s the file, and subsequent elements represent the individual workshee +ts. The label key pair contains the worksheet name, access it like th +is: $workbook->[1]{label}; #Sheet1

        You're not using cpan correctly, and have not used cpanm either.

        cpanm Spreadsheet::Simple

        Just provide the module name.

Re: Module location and Setup Error Message.
by thanos1983 (Parson) on Apr 19, 2018 at 14:23 UTC

    Hello Anonymous Monk,

    For me after downloading your code it works as expected.

    Sample of code and output:

    #!/usr/bin/env perl use strict; use warnings; use Spreadsheet::ParseExcel::Simple; my $xls = Spreadsheet::ParseExcel::Simple->read("To_read.xls"); foreach my $sheet ($xls->sheets) { while ($sheet->has_data) { my @data = $sheet->next_row; print join "|", @data; print "\n"; } } __END__ $ perl test.pl Hi Excel!

    I do not know what is the error on your code as the error you report as line 6 is the for loop which means that line 4 and 5 are fine where I would expect to have a problem. Also I noticed that you have noticed your script readxls.PL rename it to readxls.pl.

    Fix your code try to install the module through CPAN as fellow Monk marto suggested and let us know if you still have a problem.

    Hope this helps, BR.

    Seeking for Perl wisdom...on the process of learning...not there...yet!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1213162]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2019-10-16 05:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?