Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding data on Excel 1

Status
Not open for further replies.

miguelfc

Programmer
Aug 5, 2004
3
VE
Hi!

I'm using perl and win32::eek:le module to extract information from an excel archive. I'm having problems with the sintaxis, I think. What my program is intended to do is search for a string and returning its position. This is the code:
while (!$i){
$valor = $Sheet->Range("A1:G500")->Find({What=>"$_[0]",After=>"A1"})->{Row};
$col = $Sheet->Range("A1:G500")->Find({What=>"$_[0]",After=>"A1"})->{Column};
$row = $valor;
$valor = $Sheet->Cells($row,$col)->{'Value'};
$i="TRUE" if ($valor=~/$_[0]$/);
}
}

This code doesn't work, and the error is on the second line. I've tried with Cell($row,$col) and it doesn't work either. I want the "A1" to be dynamic, that's the point of this.

If anyone knows about this, please give me some advise.

Bye. Sorry for my english, i'm not very good on that.
 
You may want to try using the Spreadsheet::parseExcel module from CPAN. It is specifically designed for dealing with excel, and I have always found it very easy to use.
 
Read the thread219-824783. Here I posted an example how to use the module Spreadsheet::parseExcel.
 
Hi, thanks for your help.

Using the spreadsheet module, how do I search for text patterns using regular expressions?
 
read_source();

sub read_source {

my $workbook = Spreadsheet::parseExcel::Simple->read($input_file);

my $worksheet = ($workbook->sheets())[0];

while ($worksheet->has_data()) {
my @fields= $worksheet->next_row();
$value_col1="$fields[0]";
$value_col2= "$fields[1]";
$value_col3 = "$fields[2]";
$value_col4 = "$fields[3]";
compare_values();
}

}

}


# Example checking Values from column 1
# Also you could check against the array @fields (remember # that @fields is local, so you should check it after the
# line (my @fields= $worksheet->next_row();)


sub compare_values{
$found ==1 and $cont++ if ($value_col1 eq $string_to find);
}

print "I have found the string $string $cont++ times\n";



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top