#!/usr/bin/perl -w use strict; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; #$Win32::OLE::Warn = 3; # die on errors... # get already active Excel application or open new my $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); # open Excel file my $Book = $Excel->Workbooks->Open("u:/file.xls"); my $Book1 = $Excel->Workbooks->Open("u:/v3.xls"); # select worksheet number 1 (you can also select a worksheet by name) my $Sheet = $Book->Worksheets(1); my $Sheet1 = $Book1->Worksheets(1); my $val1; my $cnt=0; my $line; foreach my $row (1..3000) { foreach my $col (1) { my $val; next unless defined $Sheet->Cells($row,1)->{'Value'}; $val = $Sheet->Cells($row,1)->{'Value'}; #findl($val); for($cnt=1;$cnt<=65536;$cnt++){ $val1 = $Sheet1->Cells($cnt,1)->{'Value'}; if ((defined $val1) && (index($val1,$val) != -1)){ $line =$cnt if (!defined $line); $Sheet->Cells($row,2)->{'Value'}= *; last; } } } } $Book->SaveAs ("u:/file.xls") ; # clean up after ourselves $Book->Close; $Book1->Close;