rails导出CSV XLS 中文乱码解决办法
CSV.generate(options) do |csv| csv << column_names all.each do |product| csv << product.attributes.values_at(*column_names) end end.encode('gb2312', :invalid => :replace, :undef => :replace, :replace => "?")
send_data xml_data.encode('utf-8'),
:type => 'text/xml; charset=utf-8; header=present',
:filename => "data.xml"
重点在最后一行
导出方法 http://railscasts.com/episodes/362-exporting-csv-and-excel
导入 http://railscasts.com/episodes/396-importing-csv-and-excel