Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Win32::OLE & Excel help

by prasadbabu (Prior)
on Jan 14, 2009 at 09:17 UTC ( #736160=note: print w/ replies, xml ) Need Help??


in reply to Win32::OLE & Excel help

Hi imrags,

I have not benchmarked, but by adding next we can avoid some extra executions. It is not going to boost more performance, but slight improvement will be there.

use strict; use warnings; for my $i (1 .. $LastRow) { if ($Sheet->Range("E$i")->{Value} =~ /MSD/){ next; } else{ $CB_COUNT++; if ( $Sheet->Range("J$i")->{Value} !~ /No_/i){ $NM_COUNT++; } }

OP has updated the code. Posted solution for the previous one.
update: Removed extra 'if' statement in 'else' part.

Prasad


Comment on Re: Win32::OLE & Excel help
Download Code
Re^2: Win32::OLE & Excel help
by gone2015 (Deacon) on Jan 14, 2009 at 11:20 UTC

    You'll get a little extra benefit if you avoid entering a BLOCK, so:

    for my $i (1 .. $LastRow) { next if ($Sheet->Range("E$i")->{Value} =~ /MSD/) ; $CB_COUNT++; next if ($Sheet->Range("J$i")->{Value} =~ /No_/i) ; $NM_COUNT++; }
    but as noted elsewhere, the major time cost is probably in the OLE calls.

    Is it possible to pull a range into an array ? I'm thinking: @stuff = $Sheet->Range("J1:J$lastrow") ?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://736160]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2015-07-03 17:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (55 votes), past polls