How to read attached excel files with roo gem
My view is
<%= form_for @hotel, :url => { :action => "create_by_excel_sheet" } do |f| %>
<%= f.file_field :excel_sheet %>
<%= f.submit %>
<%end%>
I tried
def create_by_excel_sheet
xlsxFile = params[:hotel][:excel_sheet]
prefix_tmp_path = xlsxFile.path
filename = xlsxFile.original_filename
fullname = File.join(prefix_tmp_path,filename)
s = Roo::Excelx.new(fullname)
for i in 1..14
puts s.cell(i,3)
end
end
But I receive an error *** IOError Exception: file /tmp/RackMultipart20130921-4175-165dgyw/hotel_information.xlsx does not exist
and edit the code and tried
Roo::Excelx.new(xlsxFile.path)
get the error
TypeError Exception: /tmp/RackMultipart20130921-4175-165dgyw is not an Excel-xlsx file