in reply to Re^7: read from xlsx is throwing error
in thread read from xlsx is throwing error

So far, you have been shown three approaches to diagnose where your problem might be.

If you have already tried all three, please report back with the output of the suggested commands.

If you have not tried the suggestions, why not? I recommend that you try them and report back with the output.

Replies are listed 'Best First'.
Re^9: read from xlsx is throwing error
by ajaykannan (Novice) on Dec 19, 2016 at 22:16 UTC

    thank you for the patience and time upone me corion i tried all of the methods in which you freinds suggested me .But still am not getting exact output. Here is the command used install install install Spreadsheet::Read and result is nolock_cpan> install Spreadsheet::Read Spreadsheet::Read is up to date (0.69). my code is

    #!/usr/bin/perl use strict; use warnings; use Spreadsheet::Read qw(ReadData); my $book = ReadData ('simple.xlsx'); say 'A1: ' . $book->[1]{A1}; my @rows = Spreadsheet::Read::rows($book->[1]); foreach my $i (1 .. scalar @rows) { foreach my $j (1 .. scalar @{$rows[$i-1]}) { say chr(64+$i) . " $j " . ($rows[$i-1][$j-1] // ''); } }

      Try running this script and post the results which will be in a file called perlmonks.txt

      #!perl use strict; use Cwd; open my $log,'>','perlmonks.txt' or die "$!"; select $log; print getcwd(); print " $0 $^V \@INC "; print join "\n", @INC; print "\nPATH\n"; print join "\n",grep (/perl/i, split ';',$ENV{PATH}); print "\n\n"; my @mod = qw( Spreadsheet::Read Spreadsheet::WriteExcel Spreadsheet::ParseXLSX ); for (@mod){ eval ("use $_"); if ($@){ print "ERROR - $@\n"; } else { print "OK - $_\n"; } } select STDOUT; print "Done - see perlmonks.txt";
      poj

        That's a useful piece of code, poj. I'm gonna save that off for a time when I might need it myself.

        Thanks,

        smknjoe

      In my reply, I showed you three commands you can run to better diagnose where the module might be installed.

      I did show you these commands so that you can run them on your machine and diagnose where the Read.pm file was installed.

      Have you run these commands?

      What was their output?

      What problems did you encounter?

      It is hard for us to give you meaningful advice if you ignore all steps that allow us to diagnose your problem better.

      I do not have your xlsx file, so I cannot check with *your* data, but when I do with a simple .xlsx file, all goes well:

      $ cat pm1178127.pl #!/pro/bin/perl use 5.18.0; use warnings; use Spreadsheet::Read; my $book = ReadData ("julia-good.xlsx"); say "Book was parsed using $book->[0]{parser}-$book->[0]{version}"; say "A1: ", $book->[1]{A1}; my @rows = Spreadsheet::Read::rows ($book->[1]); foreach my $i (1 .. scalar @rows) { foreach my $j (1 .. scalar @{$rows[$i-1]}) { say chr (64 + $i) . " $j " . ($rows[$i - 1][$j - 1] // ""); } } $ xlscat julia-good.xlsx id|text 1|a 2|b 3|c 4|d 5|e 6|f 7|g 8|h 9|i 10|j 2 x 11 $ perl pm1178127.pl Book was parsed using Spreadsheet::ParseXLSX-0.27 A1: id A 1 id A 2 text B 1 1 B 2 a C 1 2 C 2 b D 1 3 D 2 c E 1 4 E 2 d F 1 5 F 2 e G 1 6 G 2 f H 1 7 H 2 g I 1 8 I 2 h J 1 9 J 2 i K 1 10 K 2 j $

      So my first hunch is that your .xlsx cannot be parsed by your XLSX parser.


      Enjoy, Have FUN! H.Merijn