Hey guys! I want to export the page Info to Excel ,who can tell me how can i do this? thank you!
A:
Something like this might help:
http://blog.dhavalparikh.co.in/2009/04/export-to-excel-in-ruby-on-rails/
Controller
class UserController < ApplicationController
def export
headers['Content-Type'] = "application/vnd.ms-excel"
headers['Content-Disposition'] = 'attachment; filename="report.xls"'
headers['Cache-Control'] = ''
@users = User.find(:all)
end
View
export.html.erb
<%= link_to "Export as Excel", export_person_url %>
_report.html.erb
<table border="1">
<tr>
<th>Name</th>
</tr>
<% @users.each do |u| %>
<tr>
<td><%= u.name %></td>
<% end %>
</tr>
</table>
brendan
2010-04-29 01:57:26
thank you for you help! now i use the spreadsheet plugin to solve the problem
Small Wolf
2010-04-29 10:03:53
A:
This throws a security exception with excel 2007, so its not much use.
j
slotishtype
2010-08-03 14:00:36