ggupta
ggupta

Reputation: 59

read data from excel in perl

I am trying to read data from excel, i have below code.

    #!/usr/bin/perl
    use strict;
    use warnings;
    use 5.010;
    use feature 'say';
    use Spreadsheet::XLSX;
    use Spreadsheet::Read qw(ReadData);
    my $book = ReadData ('/tmp/simple.xlsx');

    say 'A1: ' . $book->[1]{A1};

    my @row = Spreadsheet::Read::row($book->[1], 1);
    for my $i (0 .. $#row) {
        say 'A' . ($i+1) . ' ' . ($row[$i] // '');
    }

    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] // '');
        }
    }

getting the error as:

        Can't locate OLE/Storage_Lite.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/local/share/perl5/Spreadsheet/ParseExcel.pm line 21.
    BEGIN failed--compilation aborted at /usr/local/share/perl5/Spreadsheet/ParseExcel.pm line 21.
    Compilation failed in require at /usr/local/share/perl5/Spreadsheet/XLSX.pm line 14.
    BEGIN failed--compilation aborted at /usr/local/share/perl5/Spreadsheet/XLSX.pm line 14.
    Compilation failed in require at read_excel.pl line 6.
    BEGIN failed--compilation aborted at read_excel.pl line 6.

I have every related module. but as per error when i am going to download OLE/Storage_Lite.pm from the CPAN, page is going blank, and from metacpan below error is coming.

        https://cpan.metacpan.org/authors/id/M/MS/MSCHWARTZ/OLE-Storage-0.386.tar.gz
    Resolving cpan.metacpan.org... 151.101.128.249, 151.101.192.249, 151.101.64.249, ...
    Connecting to cpan.metacpan.org|151.101.128.249|:443... connected.
    ERROR: certificate common name “a.ssl.fastly.net” doesn’t match requested host name “cpan.metacpan.org”.
    To connect to cpan.metacpan.org insecurely, use ‘--no-check-certificate’.

Upvotes: 0

Views: 475

Answers (1)

Mohit
Mohit

Reputation: 608

Try downloading the module tar zip from cpan or metacpan. Then build the module locally using any make utility(e.g.dmake). You can find more info for building module locally from here.

Upvotes: 1

Related Questions