From: Rase In Date: 2009-05-09T04:09:12+09:00 Subject: Re: Export to Excel from SciTE Result Log Jason, please find my code...i m able to open the Excel but im not able to put the values, it shows errors. require 'watir' ie=Watir::IE.attach(:title,/.*Policy.*/) ie.links.each{|link| #'Searching the Links in the Website if link.id =~/policyForm:autoMainTabsList/ #Giving the Link Id using the Regular Expression link.click # Click the Link and higlight it ie.links.each{|sub_link| # go into the sublink from the Link # Giving sublink ids if sub_link.id=~/(policyForm:basegeneralTabsList)/ || sub_link.id=~/(policyForm:baseInsuredTabsList)/ || sub_link.id=~/(policyForm:underwritingTabsList)/ || sub_link.id=~/(policyForm:driverTabsList)/|| sub_link.id=~/(policyForm:vehicleTabsList)/ sub_link.click # Click the Submink under specified id elements = get_text_fields(ie) # getting the Fields value and Name elements.each{|e| # Loop fo each p 'Name - ' + e.name #Prinitng the Name of the Fields p 'Value - ' + e.value # Printing the Value of the Fields } end } end } I iterating the Loop with different User id, so the Name and value differs...now i have to export it to the Excel. 1. Let me know where to Start the Excel Coding, opening the Excel, how to load the contents to Excel,how to name with Header (Name,whet we are getting) 2. Put the Label names or how to map the Fields name in the Excel Sorry to bother you a lot, awaiting your feedback ------------------------ Jason Lillywhite wrote: > Well, actually you may not need the csv library yet. But working with > Excel means you may want to take a look at it. > > Anyway, maybe you could do something like this: > > elements = [{:name => 'John', :value => 35}, {:name => 'Henry', :value > => 45}, {:name => 'Sue', :value => 23}] > > File.open("out.csv", "w") do |row| > row << "Name, Value\n" > elements.each do |e| > row << "#{e[:name]}, #{e[:value]}\n" > end > end > > that should return a csv file in your directory that looks like this > when opened in a spreadsheet: > > Name Value > John 35 > Henry 45 > Sue 23 > > I am a newbie too, so someone else might have a way better plan. PS - > I'm assuming your 'elements' is an array of hashes. -- Posted via http://www.ruby-forum.com/.