I need some gem/plugin to create an Excel spreadsheet with formulas to use in my Rails application. Any suggestions?

- 22,383
- 32
- 112
- 130

- 26,966
- 21
- 76
- 96
-
If you create a CSV with formulas in the columns, will Excel parse those formulas when it loads the CSV? – jaredonline May 04 '11 at 19:07
-
If you're on Linux, it's a duplicate of http://stackoverflow.com/questions/2227973/generating-excel-documents-with-ruby . If you're on Windows, you can use win32ole – Andrew Grimm May 09 '11 at 23:41
4 Answers
I've used Roo and it's quite good and easy to do spreadsheet processing (once you get all the gem dependencies installed). However, it doesn't support formulas natively. It won't eval the formula and return the result (this would be difficult I think -- use the excel engine?) but it will give you the text of the formula, for example:
=SUM(.A1,.B1)
It'd be pretty easy to handle this specific case but if you have many different formulas and functions then rolling your own evaluator is going to be difficult. Going and getting A1 and B1 to add them together is very doable with Roo. It's just a question of how complex your formulas are.

- 3,242
- 4
- 26
- 35
-
Roo is gem for __parsing__ (read only) Excel, not for creating new files: `Currently only read-access is implemented. Google spreadsheets can be read and written` – fl00r May 04 '11 at 18:12
-
I think you should create blank Excel file with formulas and then fill it with Rails. Because you can't create formulas with Ruby.

- 82,987
- 33
- 217
- 237
-
I do not know the number of columns and rows beforehand. So I can't take this approach. – Vijay Dev May 04 '11 at 18:26
-
There's a spreadsheet gem listed on RubyGems but having never used it I can't recommend it.

- 4,707
- 4
- 29
- 38
-
That doesn't have formula support yet. http://spreadsheet.rubyforge.org/classes/Spreadsheet/Formula.html – Vijay Dev May 04 '11 at 18:30