[英]Export as CSV and Excel in Ruby on Rails
I have a list of email-ids stored in a variabe ( Say @emails
). 我有一个存储在
@emails
中的电子邮件ID列表(说@emails
)。 This list is being generated in a controller inside an action. 该列表是在动作内部的控制器中生成的。 This action is specifically made for this purpose.
此操作是专门为此目的而进行的。 Now I want to enable the user to download this list other than viewing it as HTML.
现在,我希望使用户能够下载该列表,而不是以HTML形式查看它。 I am unable to find a way of doing it.
我找不到解决办法。 (Also there is no model associated with emails so I think the approach described in Railscasts won't work here)
(也没有与电子邮件关联的模型,因此我认为Railscasts中描述的方法在这里行不通)
I've been using the axlsx_rails gem for this. 我一直在使用axlsx_rails gem。 Easy to install and to use.
易于安装和使用。
https://github.com/randym/axlsx https://github.com/randym/axlsx
for that follow these links:- 为此,请点击以下链接:
http://railscasts.com/episodes/362-exporting-csv-and-excel http://railscasts.com/episodes/362-exporting-csv-and-excel
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.