Rails中2数据在一列中,而不是排明智的CSV写的Rails
开发应用,我从数据库值generating CSV
文件。获取emails of users
并生成CSV,但写入emails in one column instead of Row.
我试了很多,但没有找到任何解决方案。
下面写CSV的代码controller file
@users = User.all
tempArr = []
@users.each do |u|
tempArr << u.email
end
respond_to do |format|
format.csv {
send_data tempArr.to_csv, :type => "text/csv", :filename => "usercsv.csv"
}
end
像
[email protected] [email protected] [email protected]
数据显示想要显示
[email protected]
[email protected]
[email protected]
任何人都有一个想法或诱骗到sortout。
在此先感谢
你需要数据的行或列,尚不清楚我? –
重复:http://stackoverflow.com/questions/13065130/rails-write-a-csv-file-column-wise –
@OlegSobchuk更新的问题,请检查它。下面显示我要如何显示。 – user1780370