Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Simple Question - Simple Answer, I hope.

by basicdez (Pilgrim)
on Mar 24, 2008 at 14:41 UTC ( [id://675908]=perlquestion: print w/replies, xml ) Need Help??

basicdez has asked for the wisdom of the Perl Monks concerning the following question:

Please help me out and let me know what the general process is when using this Win32::OLE process. I believe that I know it, but want to check it against all of the wisdom that is willing to help me out.
{ $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); $Excel->{'Visible'} = 0; $book = $Excel->Workbooks->Open("$dirpath\\$xls"); $worksheet = $book->Worksheets(1); $row = 0; $read_xls++; while ($read_xls) { $row++; $excel_data = $worksheet->Range("A$row:Z$row")->{'Value'}; $col1_data = $excel_data->[0][0]; $col2_data = $excel_data->[0][1]; $col1_data =~ s/\s*$//; $col2_data =~ s/\s*$//; if ($col1_data =~ /^MDLS/i) { $found_mdls++; $col = 0; } next unless $found_mdls; unless ($col1_data) { $found_mdls = ""; $read_xls = ""; last; } $model = $col1_data; $spec = $col2_data; $prod2 = $model; $Excel->Workbooks->Close(); }
I forgot to put this in, but what is the value of 0 and 1 in the form of the Worksheet format. I believe that they just get concatenated with the next set of values, but really want to make sure.

just so you all know, this has been a painful post for me. I have felt stupid, then smart, then stupid all over again. I do know now what I was looking for and have figured out the flow of this program. I was on the right track and thanks to a few kind monks, I have found my way with this program.

Although, I have learned that this place is majorly competive and I am not one of the top monks, I am humble enough to carry forward and ask another question if I need to, in order to get the help that I need.

Peace, ((love)) and Code

Replies are listed 'Best First'.
Re: Simple Question - Simple Answer, I hope.
by amarquis (Curate) on Mar 24, 2008 at 15:12 UTC

    Just based on my limited experience working with Excel files in Perl, you look to be going about it fine. Is there a particular problem or issue you are having? Or is the result of your code not what you expect?

    You might benefit from adding strict, or at least declaring variables via my in this block. It is difficult as a reader who doesn't know what you are trying to do to tell the difference in your code between globals defined elsewhere and globals you are springing into existence in this block.

Re: Simple Question - Simple Answer, I hope.
by NetWallah (Canon) on Mar 24, 2008 at 17:25 UTC
    Instead of writing code to do your search, you could make Excel do the work for you, by using the Find method of the Range object.

    Details at MSDN.

         "As you get older three things happen. The first is your memory goes, and I can't remember the other two... " - Sir Norman Wisdom

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://675908]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-04-19 14:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found