From: Daniel Navarro Date: 2010-10-14T02:37:55+09:00 Subject: Re: Excel and Ruby --20cf3040ee60651eca0492830dd2 Content-Type: text/plain; charset=ISO-8859-1 oops sorry I initialized alot of Constants there. anyways here is my updated code it works fine except it is returning multiple values of the result. Any Ideas? require 'win32ole' xl = WIN32OLE.connect('Excel.Application') wb = xl.ActiveWorkbook ws = xl.ActiveSheet ws.Range('N2').each do |cell| ws.Range('P3501:V3501').each do |days| contentsN = cell.value cellContentsN = contentsN.scan(/\w+/) dayofweek = %w{Monday Tuesday Wednesday Thursday Friday Saturday Sunday} month = %w{Janurary Feburary March April May June July August September October November December} comparedayofweek = dayofweek & cellContentsN comparemonth = month & cellContentsN p comparedayofweek p comparemonth end end On Wed, Oct 13, 2010 at 3:19 AM, Dan Sr. wrote: > Hello all, > > I'm just doing some data entry work and thought it would be fun to > automate my work with Ruby.(yes I could do this in VB but what fun is > that?) > > What I am doing is putting column N into an Array. And then comparing > the array to an already specified array to get the value. If that value > is present then I want to put an X in column P-V, Time in w-x and dates > in y-z. so far I have got everything that I have coded to work correctly > but haven't put classes or any structure to it. Just wanted to see if > what I was doing was ruby~esque so far and if anyone had any cool tricks > or see something I am doing wrong. (My first program automating excel or > really anything in ruby) I have automated some files with tutorials but > this is my first attempt on automating anything for any relevant > purpose. It's only half 1/4 or 1/8 written so far. > My goal is to loop through the items one by one, incrementing +1 to the > next cell until I reach the end of the file. > if __FILE__ == $0 > # TODO Generated stub > require 'win32ole' > xl = WIN32OLE.connect('Excel.Application') > wb = xl.ActiveWorkbook > ws = xl.ActiveSheet > ws.Range('N1').each do |cell| > ws.Range('P1:V1').each do |days| > ContentsN = cell.value > CellContentsN = ContentsN.scan(/\w+/) > Dayofweek = %w{Monday Tuesday Wednesday Thursday Friday Saturday > Sunday} > Month = %w{Janurary Feburary March April May June July August > September October November December} > 01.upto(31){|Day|} > Comparedayofweek = Dayofweek & CellContentsN > Comparemonth = Month & CellContentsN > Compareday = Day & CellContentsN > end > end > end > > -- > Posted via http://www.ruby-forum.com/. > > -- Daniel Navarro 9035612340 --20cf3040ee60651eca0492830dd2--