简体   繁体   English

在perl中从excel读取数据

[英]read data from excel in perl

I am trying to read data from excel, i have below code. 我正在尝试从Excel读取数据,我有以下代码。

    #!/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. 但是按照错误,当我要从CPAN下载OLE / Storage_Lite.pm时,页面空白,并且从metacpan下面出现错误。

        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’.

Try downloading the module tar zip from cpan or metacpan . 尝试从cpanmetacpan下载模块tar zip。 Then build the module locally using any make utility(egdmake). 然后使用任何make实用程序(egdmake)在本地构建模块。 You can find more info for building module locally from here . 您可以从此处找到有关在本地构建模块的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM