error accessing 2 sheets of an excel

12 views
Skip to first unread message

Achyuth Pydmarri

unread,
Aug 29, 2018, 1:07:53 AM8/29/18
to spreadsheet
Hello all,

I am trying to access multiple sheets of a excel file at a time and facing issue, below is the code


  book = Spreadsheet.open(file_name)

  sheet1 = book.worksheets.find { |sheet| sheet.name == sheetname1 } 
  sheet2 = book.worksheets.find { |sheet| sheet.name == sheetname2 } 
5.upto(sheet2.rows.count) do |findrownum|
0.upto(sheet2.column_count) do |findcolnum|
end
end


error which i am getting is , not sure why it is not able to read sheet2 

NoMethodError: undefined method `rows' for nil:NilClass
Reply all
Reply to author
Forward
0 new messages