From: Parvinder Ghotra Date: 2006-06-13T22:29:15+09:00 Subject: Re: reading data from excel Madan Manoharan wrote: > On 6/5/06, Parvinder Ghotra wrote: >> Hi, >> I'm brand new to Ruby. >> Can somebody share their expertise on how to open and read data from >> excel using ruby? >> Thanks in advance. > > A very rudimentary version that shows the logic: > > require 'win23ole' > > application = WIN32OLE.new('Excel.Application') > worksheet > =application.Workbooks.Open(excelFileName).Worksheets(workSheetName) > worksheet.Activate > > contLoop = true # Dummy counter for the loop > > while contLoop do > colVal = worksheet.Cells(row, column).Value > > if (colVal) then > # This field is not NIL, this means that this row contains a > entry > # Get the SecurityObject corresponding to the cusip, and > get the coupon > do processing .... > else > # This signifies the end - no cash column value, no short > name value. > # End the loop > contLoop = false > end > # go to the next Row > row += 1 > end > > # we are done > application.Workbooks.Close > > > >> And also any suggestions on where/how to learn Ruby would be very >> helpful and appreciated. >> > > Pickaxe is a great book. You can find an online version at > http://www.ruby-doc.org/docs/ProgrammingRuby/html/index.html > > All the best, > -Madan. Thanks everybody for your time and help. Issue: I'm getting an error "undefined local variable row" at line > colVal = worksheet.Cells(row, column).Value Thanks for your help, -Parvinder -- Posted via http://www.ruby-forum.com/.