WaltSteadman
MIS
Greetings all,
I found most of my solution here already for using Spreadsheet:
arseExcel and with the code I got here, I can get the script to parse out each cells information and print it for me. What I am trying to do is have the user input two values and as it goes down each row, it will check the first value against Column 1 and if that is correct it will check the second input value against Column 3 and if those are both true, then I want the script to print out information from Column 4, 5 and 6 of the row it is on.
Example Data:
Start | Row1 | Row2 | Row3 | Row4 | Row5 | Row6 |
--------------------------------------------------
Col1 | 3 | Red | zz | 35 | M | Blue |
Col2 | 4 | Blue | ll | 22 | F | Brown |
Col2 | 6 | Blue | zz | 27 | M | Blue |
Col2 | 8 | Blue | ll | 36 | M | Brown |
Col2 | 3 | Blue | ll | 22 | F | Brown |
Col2 | 4 | Blue | zz | 45 | M | Blue |
So if the User input 3 and zz then the results would print
34
M
Blue
I have tried to get add some if statements to the below code but when I do, it just does a continual return and I have to break out of it to get it to stop so I know I am doing something simple wrong, just going nuts trying to figure it out.
I added the field values I was looking for in this script just to test it and then instead of having it print the column information, I just had it print "Match" and when I run it, it just continually prints MatchMatchMatchMatch etc..
TIA for any assistance:
I found most of my solution here already for using Spreadsheet:
Example Data:
Start | Row1 | Row2 | Row3 | Row4 | Row5 | Row6 |
--------------------------------------------------
Col1 | 3 | Red | zz | 35 | M | Blue |
Col2 | 4 | Blue | ll | 22 | F | Brown |
Col2 | 6 | Blue | zz | 27 | M | Blue |
Col2 | 8 | Blue | ll | 36 | M | Brown |
Col2 | 3 | Blue | ll | 22 | F | Brown |
Col2 | 4 | Blue | zz | 45 | M | Blue |
So if the User input 3 and zz then the results would print
34
M
Blue
I have tried to get add some if statements to the below code but when I do, it just does a continual return and I have to break out of it to get it to stop so I know I am doing something simple wrong, just going nuts trying to figure it out.
I added the field values I was looking for in this script just to test it and then instead of having it print the column information, I just had it print "Match" and when I run it, it just continually prints MatchMatchMatchMatch etc..
TIA for any assistance:
Code:
CODE
===================================================
#! /usr/bin/perl
use strict;
use Spreadsheet::ParseExcel;
my $oExcel = new Spreadsheet::ParseExcel;
my $field1 = "3";
my $field2 = "zz";
my $oBook = $oExcel->Parse('netgear.xls');
my($iR, $iC, $oWkS, $oWkC);
for(my $iSheet=0; $iSheet < $oBook->{SheetCount} ; $iSheet++)
{
$oWkS = $oBook->{Worksheet}[$iSheet];
for (my $iR = $oWkS->{MinRow} ; defined $oWkS->{MaxRow} && $iR <= $oWkS->{MaxRow} ; $iR++)
{
for(my $iC = $oWkS->{MinCol} ; defined $oWkS->{MaxCol} && $iC <= $oWkS->{MaxCol} ; $iC++)
{
$oWkC = $oWkS->{Cells}[$iR][$iC];
if ($iC = 1)
{
if ($oWkC = $field1)
{
if ($iC = 3)
{
if($oWkC = $field2)
{
print "Match"
}
}
}
}
}
}
}