Name Error in Excel Uninitalized Contant in ‘roo’

calendar_today Asked Mar 25, 2013
thumb_up 11 upvotes
history Updated April 16, 2026

Question posted 2013 · +3 upvotes

I am trying to read an Excel file in Ruby On Rails. I have done coding like this for reading the cell content from the Excel sheet.

def test
 require 'rubygems'
 require 'iconv'
 require 'roo'

 s = Excel.new("C:/Sites/hmmsapp/Book1.xls")
 s.default_sheet = s.sheets.first

 1.upto(4) do |line|
   roll = s.cell(line,'A')
   puts "#{roll} -------------"
 end
end

But on running this it always gives me this error.

NameError in HostelController#test

uninitialized constant HostelController::Excel

I have also included iconv as per suggestions for this problem. But there is no change in error. Please give some light to removing this error & to read the excel file properly.

Accepted answer +11 upvotes

Try Roo::Excel.new

Or Roo::Spreadsheet.new

Top excel Q&A (6)

+11 upvotes ranks this answer #67 out of 167 excel solutions on this site .