Rails中导出excel的快速简便的方法

阅读更多

controller

 

 

  def to_excele
    headers['Content-Type'] = "application/vnd.ms-excel"
    headers['Content-Disposition'] = 'attachment; filename="report.xls"'
    headers['Cache-Control'] = ''
    @posts = Post.find(:all)
    render :layout => false
  end

 

 

view

 


  
  
  excele表格
  
  

  <%@posts.each do |post|%>

<% end %>
标题
<%=post.title%>

 

from:http://bot.iteye.com/blog/442422

你可能感兴趣的:(rails,excel,excel,ruby,excel,ruby)