kishore.lakshman has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, I am trying to read a value from a excel sheet and trying to see if the same exists in another excel sheet. I have tried to use the "Spreadsheet::Engine::Function::FIND" module, but it didn't help. Please let me know if there are any other ways i could accomplish this. Thanks in advance!!!

Replies are listed 'Best First'.
Re: Perl Excel Help
by ww (Archbishop) on Dec 29, 2011 at 20:44 UTC
Re: Perl Excel Help
by thomas895 (Deacon) on Dec 29, 2011 at 20:02 UTC

    You may wish to try the module DBD::Excel. That way, you can also use SQL to query the spreadsheet.

    I don't know if that's what you're trying to accomplish, but it's worth a shot.

    ~Thomas~
      i tried the DBD module, getting a output something like, Use of reference "Spreadsheet::ParseExcel::SaveParser::Worksheet=HASH(0x248efc4)" as array index at C:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 2430. Use of reference "Spreadsheet::ParseExcel::SaveParser::Worksheet=HASH(0x248efc4)" as array index at C:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1208. Use of reference "Spreadsheet::ParseExcel::SaveParser::Worksheet=HASH(0x248efc4)" as array index at C:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1208. Use of reference "Spreadsheet::ParseExcel::SaveParser::Worksheet=HASH(0x248efc4)" as array index at C:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1213. Use of reference "Spreadsheet::ParseExcel::SaveParser::Worksheet=HASH(0x248efc4)" as array index at C:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1213. Use of reference "Spreadsheet::ParseExcel::SaveParser::Worksheet=HASH(0x248efc4)" as array index at C:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1218. Use of reference "Spreadsheet::ParseExcel::SaveParser::Worksheet=HASH(0x248efc4)" as array index at C:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1218. Use of reference "Spreadsheet::ParseExcel::SaveParser::Worksheet=HASH(0x248efc4)" as array index at C:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1223. Use of reference "Spreadsheet::ParseExcel::SaveParser::Worksheet=HASH(0x248efc4)" as array index at C:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1223. Use of reference "Spreadsheet::ParseExcel::SaveParser::Worksheet=HASH(0x248efc4)" as array index at C:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1223. Use of reference "Spreadsheet::ParseExcel::SaveParser::Worksheet=HASH(0x248efc4)" as array index at C:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 2430. Use of reference "Spreadsheet::ParseExcel::SaveParser::Worksheet=HASH(0x248efc4)" as array index at C:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1208. Use of reference "Spreadsheet::ParseExcel::SaveParser::Worksheet=HASH(0x248efc4)" as array index at C:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1208. Use of reference "Spreadsheet::ParseExcel::SaveParser::Worksheet=HASH(0x248efc4)" as array index at C:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1213. Use of reference "Spreadsheet::ParseExcel::SaveParser::Worksheet=HASH(0x248efc4)" as array index at C:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1213. Use of reference "Spreadsheet::ParseExcel::SaveParser::Worksheet=HASH(0x248efc4)" as array index at C:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1213. Use of reference "Spreadsheet::ParseExcel::SaveParser::Worksheet=HASH(0x248efc4)" as array index at C:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1218. Use of reference "Spreadsheet::ParseExcel::SaveParser::Worksheet=HASH(0x248efc4)" as array index at C:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1218. Use of reference "Spreadsheet::ParseExcel::SaveParser::Worksheet=HASH(0x248efc4)" as array index at C:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1223. Use of reference "Spreadsheet::ParseExcel::SaveParser::Worksheet=HASH(0x248efc4)" as array index at C:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1223. Use of reference "Spreadsheet::ParseExcel::SaveParser::Worksheet=HASH(0x248efc4)" as array index at C:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1223.
Re: Perl Excel Help
by davies (Monsignor) on Dec 31, 2011 at 23:51 UTC

    I'm far from sure what you want, but I'll try anyway. However, let me start by stating my assumptions.

  • "Sheet" means a sheet and not a workbook (file).
  • "if" indicates that you are interested only in a boolean. A single occurrence or a hundred makes no difference. Once the value has been found you are not interested in anything else.
  • "the same" refers to "value" and means that you are interested in the value returned and not in any formula that gives rise to it. You also want a precise match and do not have problems with the accuracy of internal storage of binary representations of numbers.
  • "another" means precisely one other sheet which is known to you in advance, rather than any other sheet.
  • Both sheets are in the same workbook.
  • The following code works for me. If you make the assignments in lines 11 and 13 the same, you will get "Found" printed.

    use strict; use warnings; use Win32::OLE; my $xl = Win32::OLE->new('Excel.Application'); $xl->{SheetsInNewWorkbook} = 2; $xl->{Visible} = 1; my $wb = $xl->Workbooks->Add; my $cellSource = $wb->Sheets(1)->Cells(1,1); $cellSource->{Value} = 1; my $cellTarget = $wb->Sheets(2)->Cells(2,2); $cellTarget->{Value} = 2; my $addFound = $wb->Sheets(2)->Cells->Find({ What => $cellSource->{Value}, LookIn => -4163 #xlValues }); if ($addFound) {print "Found\n"} else {print "Not found\n"}

    Regards,

    John Davies