Segfault in win32ole

I'm trying to use Ruby to read an Excel spreadsheet with 853 rows and
6 columns. Here's the code:

···

----------
require 'win32ole'
filename = 'G:\My Documents\CXL\bigfile.xls'

xlApp = WIN32OLE.new('Excel.Application')
xlBook = xlApp.Workbooks.Open(filename)

sheet = 1
row1 = 1; col1 = 1
row2 = 800; col2 = 6
sht = xlBook.Worksheets(sheet)
data = sht.Range(sht.Cells(row1,col1), sht.Cells(row2,col2)).Value
----------

  When I run this, ruby segfaults:

J:\scripts>ruby win32crash.rb
win32crash.rb:15: [BUG] Segmentation fault
ruby 1.8.1 (2003-12-25) [i386-mswin32]

This application has requested the Runtime to terminate it in an
unusual way.
Please contact the application's support team for more information.

  Any ideas what's going on here? I'm running under Windows XP
(without SP2).

  I tried reading the spreadsheet a row at a time as a workaround, but
after reading 50 or 60 rows, the same problem occurs.

  FWIW, I tried running the same code under Python (slightly modified,
of course), and it ran just fine.

  Any help would be much appreciated!

Jim

Jim,

I had problems writing to large ranges in Excel sheets, but I "solved"
the problems by moving to this version of Ruby:

ruby 1.8.2 (2004-06-29) [i386-mswin32]

The version's from the Windows one-click installer, and it includes a
version of win32ole.so that worked well with Excel. I haven't used the
latest and greatest one-click installer yet, because I have too many
users of the above version. I know, though, that the newest one handles
large writes very well (I wanted to test the latest one-click
installer.)

So, try using the latest one-click installer to see if it solves your
reading problems. Or you can grab the win32ole.so from the one-click
installer, and plop it into your existing Ruby installation.

--Wayne

Yes, 1.8.2 seems to fix all segfault problems with win32ole. Older versions of win32ole have confirmed bugs, but the one that comes with 1.8.2 has never thrown a segfault on me.

Brian

WayneFChin@gmail.com wrote:

···

Jim,

I had problems writing to large ranges in Excel sheets, but I "solved"
the problems by moving to this version of Ruby:

ruby 1.8.2 (2004-06-29) [i386-mswin32]

The version's from the Windows one-click installer, and it includes a
version of win32ole.so that worked well with Excel. I haven't used the
latest and greatest one-click installer yet, because I have too many
users of the above version. I know, though, that the newest one handles
large writes very well (I wanted to test the latest one-click
installer.)

So, try using the latest one-click installer to see if it solves your
reading problems. Or you can grab the win32ole.so from the one-click
installer, and plop it into your existing Ruby installation.

--Wayne