Export as CSV and Excel in Ruby on Rails - ruby-on-rails

I have a list of email-ids stored in a variabe ( Say #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. 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)

I've been using the axlsx_rails gem for this. Easy to install and to use.
https://github.com/randym/axlsx

for that follow these links:-
http://railscasts.com/episodes/362-exporting-csv-and-excel

Related

Extract page number from Word document - Ruby on Rails

I'm working on an application that generates a .docx document using Caracal gem. I need a way to find out how many pages said document has, preferably directly from Caracal. Alternatively, I tried to use Yomu gem to get the page count from the metadata, as shown in this answer. However, apparently the document I'm generating does not include the page count in its metadata. Thanks in advance!

How do I add rows/columns to an existing xlsm file in Rails?

I have an existing .xlsm file in my application. I have to be able to edit it. I mean I want to add rows/columns to it. How do I do it? What are the possible solutions? I have just started learning Rails, so I am unfamiliar with most of the things.
You can use the rubyXL gem. It lets you edit xslx files e.g. worksheet[0][0].change_contents("", worksheet[0][0].formula)

rails i18n, the best way to manage localization

I'm using http://guides.rubyonrails.org/i18n.html for localization. Looks like that the only solution for updating localization is to update yml files. May be there are some solutions or gems which adds ability to update localization via application. For example we can include some gem and update localization files from our app. Is there some solutions for that?
Shameless plug for my own product here, but check out http://www.localeapp.com for a solution that works with YAML files out of the box.
Take a look at Globalize 3. It stores the translation/localization data in the database. There's also a gem to hook it up with ActiveAdmin.
Also, while you're at it, don't miss the rails-i18n gem mentioned in the guide. It translates Rails itself into many languages, so you don't have to do it yourself.
There is a great railscast to manage i18n through Redis.

Gem for surveys with images on RoR

I am a newbie on RoR and I am looking for a GEM that would create surveys and support images. I have tried Surveyor and it seems great for text only surveys (I will definitely use it again for surveys). Ideas?
Easiest way would be to generate the HTML with that gem, then use the generated HTML and put it in the html.erb and update it with the images.
You can look at the generated HTML with developer tools on your browser.
Otherwise, you will have to write it yourself or add new methods to that gem.

Is Prince the best way to create PDFs in Ruby on Rails?

After several Google searches, it appears that the way to create PDFs in Rails from HTML and CSS (versus a new markup language) is to use Prince.
With licensing at $3800 for my non-big-commercial app, I'm wondering if this is, in fact, consensus or people have an alternative they can share the whats and hows.
You may check out prawn too. Tutorial can be found on railscasts.com.
This may fit the bill: http://code.google.com/p/wkhtmltopdf/
We tried tow solutions:
using latex generate pdf, there is ruby gem code rtex
using java library iText, use it you may need rjb which allow you using java lib directly in ruby code, just like jruby, but you don't need build all you application on jruby.
I create tons of different PDF files on the fly from various data sources using Rails, including finest layout. I create need to create them for presenting products to customers.
After having tried all the tools mentioned above, Prince is the best tool for this task.
Prince's rendering quality & CSS support (better than some browsers) is its main selling point. If you're only generating documents with simple layouts, stick with Prawn.

Resources