win32ole --Dynamic lookup vs Static?

G

greg.rb

I am using 'win32ole' to script excel.
In python I use the COM makepy utility which allows faster processing
of ole commands. It doesn't need to do dynamic look ups.
Python code:
from win32com.client import Dispatch
xlApp = Dispatch("Excel.Application")

Does Ruby have a similar function?

I found 'olegen.rb' but after I generated a file, I haven't got it to
work.
-thanks
 
J

Jeff Wood

------=_Part_23304_19193778.1131481423749
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

You can simply use the WIN32OLE object ...
It's dynamic.
PickAxe2 has a great chapter on it. ruby-doc has decent information too.
j.

I am using 'win32ole' to script excel.
In python I use the COM makepy utility which allows faster processing
of ole commands. It doesn't need to do dynamic look ups.
Python code:
from win32com.client import Dispatch
xlApp =3D Dispatch("Excel.Application")

Does Ruby have a similar function?

I found 'olegen.rb' but after I generated a file, I haven't got it to
work.
-thanks


--
"http://ruby-lang.org -- do you ruby?"

Jeff Wood

------=_Part_23304_19193778.1131481423749--
 
G

greg.rb

Jeff said:
You can simply use the WIN32OLE object ...
It's dynamic.
PickAxe2 has a great chapter on it. ruby-doc has decent information too.
j.

Your answer was read the document and don't attempt to optimize???
Read I will.

PickAxe2 on page 272-3 shows the use of olegen.rb having a 40% faster.

Does anyone know what I am asking about?
 
D

Dave Burt

greg.rb said:
PickAxe2 on page 272-3 shows the use of olegen.rb having a 40% faster.

Does anyone know what I am asking about?

I know what you're talking about:

% olegen.rb "Microsoft Excel 11.0 Object Library" > excel.rb
% irb
irb> require 'excel'
irb> xl = Excel_Application_11.new
irb> xl.visible = true
irb> xl.quit

What problem were you having?

Cheers,
Dave
 
G

greg.rb

many thanks...however, something is still wrong. I am using the 1
click installer version. I had to download the olegen.rb from the RAA.
here is what happened:

C:\ruby\lib\ruby\site_ruby\1.8>olegen "Microsoft Excel 10.0 Object
Library" >excel.rb

C:\ruby\lib\ruby\site_ruby\1.8>irb
irb(main):001:0> require 'excel'
LoadError: No such file to load -- oleproperty
from
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in
`require__'
from
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in
`require'
from c:/ruby/lib/ruby/site_ruby/1.8/excel.rb:2
from
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in
`require__'
from
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in
`require'
from (irb):1
irb(main):002:0> require 'win32ole'
=> false
irb(main):003:0> require 'win32ole'
=> false
irb(main):004:0> require 'excel'
=> false
irb(main):005:0> xl=Excel_Application_10.new
NameError: uninitialized constant Excel_Application_10
from (irb):5
from :0
irb(main):006:0>
 
G

greg.rb

It worked!!!!!

irb(main):001:0> require 'excel'
=> true
irb(main):002:0> xl=Excel_Application_10.new
=> #<Excel_Application_10:0x32bde68 @progid="Excel.Application.10",
@clsid="{000
24500-0000-0000-C000-000000000046}", @dispatch=#<WIN32OLE:0x32bdc40>>
irb(main):003:0> xl.visible=1
=> 1
irb(main):004:0>

When I get a chance I will run some tests to see if it helps
performance.
Thanks.
 
G

greg.rb

It slowed things down. I guess "require 'excel.rb'" slows things down
if you aren't doing much work with excel to make a difference.
I had much more interesting results vs. python which I am posting on a
new thread. Ruby was 2x as fast as Python for accesing an Excel file
reading 1000 lines of data!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top