Could you please help me in exporting files to excel,pdf and .doc format through rails applications??
For Excel
In config/initializers/mime_types.rb
Mime::Type.register_alias "text/html", :excel
Mime::Type.register "text/x-ms-iqy", :iqy
Then in your controller handle the .iqy and .excel formats
respond_to do |format|
format.html
format.excel
format.iqy {
text = "WEB\n1\n%s" % URL_FOR_DATA_VIA_GET, :format => :excel)
render :text => text
}
end
Your template for the excel format should just be an HTML table with the data in it. The iqy format just renders text, now action template needed. You may want an application.excel.erb file that doesn't have all your navigation etc, so you get a nice clean html table. Also see this KB article for more iqy information.
For PDF
For Doc
I would suggest that you just stick with simple text or RTF. I'm not aware of any plug-ins for this, but there is probably something.
Another approach
I've used JasperReports on pure Java projects with great success. It would be possible to use the JasperServer product, JRuby, your own application wrapper, or the ruby-java bridge to generate the outputs with Jasper. See this post. Once you go part Java, you also get the wonderful JExcelApi.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With