From: Anu Sebastian Date: 2009-08-04T21:42:53+09:00 Subject: Re: Spreadsheet::ParseExcel Hi, Thanks for the response. My excel file has data in it. When i give row.inspect i get the following : # @height= @hidden=false @default_format= @outline_level=0 @formats= @idx=0 []> But it doesn't print anything inside the loop Any idea? Thanks, Anu Norman Smith wrote: > Anu Sebastian wrote: >> Hi, >> >> I am using ruby ruby 1.8.6 and spreadsheet (0.6.4). >> I am trying to oarse an excel file. >> My code is like : >> >> require 'rubygems' >> require 'spreadsheet' >> require 'parseexcel' >> equire 'parseexcel/parseexcel' >> require 'parseexcel/parser' >> >> workbook = >> Spreadsheet::ParseExcel.parse("public/downloads/commissions/google/test.xls") >> worksheet = workbook.worksheet(0) >> >> worksheet.each { |row| >> puts row.at(0).to_s >> >> } >> > > nil usually means empty rows. Also each row is an array of cells. You > could use inspect instead of to_s to see what's really there. This is > how I get data from a spreadsheet: > > ws.each { |row| > if row != nil > # > # cycle over each cell in this row if it's not an empty row > # > row.each { |cell| > if cell != nil > contents = cell.to_s('latin1') > puts("Cell Contents: #{contents}\n") > end > } > end > } -- Posted via http://www.ruby-forum.com/.