Working with excel spreadsheet

Hi there

I am working on a project in which I am loading two files - one csv the
other excel spreadsheet.

I want to find a particular element in the s’sheet according to an
id_key selected from the csv file.

I cannot find a way of extracting the info in a cell in s’sheet so that
I can compare the two values - have tried Cells and Range methods to no
avail - running ruby 1.9 and am new to Ruby.

data=Spreadsheet.open(‘plantstock.xls’)
sales_sheet = data.worksheet 0
CSV.foreach(“todays_sales.csv”, :headers => true) do |row|
plant_id, sales, returns = row[0],row[1],row[2]
@salesrets=[plant_id,sales,returns]
misales = sales.to_i
mireturns = returns.to_i
if !(misales == 0 && mireturns == 0) # ignore rows if sales and returns
0
puts ‘passed all the tests’
ronum=0
sales_sheet.each do |row|
puts ‘here is row[0]’
#cell_id = sales_sheet.Range(‘a’+ronum.to_s)[‘Value’]
cell_id = sales_sheet.Cells(0,ronum).Value
puts cell_id

Throws error: ‘undefined method Cells’

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs