in reply to Re: Searching a string in excel sheets
in thread Searching a string in excel sheets

http://www.perlmonks.org/?node_id=1121108

I saw that module and tried the example. It returns the same error which metioned in the above node.

Error: No Excel data found in file.

There someone suggested use Win32::OLE. We cant do this using Spreadsheet::ParseExcel ???

  • Comment on Re^2: Searching a string in excel sheets

Replies are listed 'Best First'.
Re^3: Searching a string in excel sheets
by Corion (Patriarch) on Aug 10, 2015 at 10:34 UTC

    That error code means that the file you passed to your program was not in a format understood by Spreadsheet::ParseExcel. Maybe your file is not an .xls file?

      My file is .xlsx formated. Is it not supported by Spreadsheet::ParseExcel. What i have to do now ???

        Find a module that reads XLSX files. A CPAN search could point you to the correct module to use.

        Date formats can be a problem with Excel, you might need to convert to match properly

        #!perl use strict; use Spreadsheet::XLSX; use Spreadsheet::ParseExcel::Utility qw(ExcelFmt); my $col1 = 1; # B my $col2 = 35; # AJ my $wb = Spreadsheet::XLSX->new ('c://temp//Book1.xlsx'); my $ws = $wb->Worksheet('Sheet1'); foreach my $row ($ws->{MinRow} .. $ws->{MaxRow}) { # column B my $c1 = $ws->get_cell($row,$col1); my $ymd = ExcelFmt('yyyy-mm-dd', $c1->unformatted) if defined $c1;; # column AJ my $c2 = $ws->get_cell($row,$col2); my $value = $c2->value if defined $c2; print "$row $ymd $value\n"; }
        poj