From: "Jesús Gabriel y Galán" Date: 2013-02-05T01:42:57+09:00 Subject: Re: Nokogiri - Data output not as expected On Mon, Feb 4, 2013 at 5:27 PM, Barry Kavanagh wrote: > "Jesús Gabriel y Galán" wrote in post > #1095159: >> I don't know the spreadsheet API, but if you need to pass the row >> number, you will need to count how many lines you filled in in the >> previous step. So create a variable added_lines = 0, outside of all >> loops, and increment it with the number of lines after adding them to >> the spreadsheet. >> Also, change sheet[i,a] to sheet1[added_lines + i, a] > Ok I made those changes but getting no output to excel, only blank with > no error code. :( require 'nokogiri' require 'open-uri' require 'spreadsheet' #Create the Spreadsheet Spreadsheet.client_encoding = 'UTF-8' book = Spreadsheet::Workbook.new sheet1 = book.create_worksheet sheet1.name = 'My First Worksheet' COLUMN = 1 added_lines = 0 #Specify our URI %w[ http://www.asus.com/Notebooks_Ultrabooks/S56CA/#specifications ].each do |url| doc = Nokogiri::HTML(open(url)) #Grab our product specifications data = doc.css('div#specifications div#spec-area ul.product-spec li') #Modify our data lines = data.map(&:text) #Output our data to the Spreadsheet lines.each.with_index do |line, i| sheet1[added_lines + i, COLUMN] = line end added_lines += lines.size end book.write 'C:/Users/Barry/Desktop/output.xls' Hope this helps, Jesus.