How to create a spreadsheet with formulas using Rails?

拜拜、爱过 提交于 2019-12-06 00:58:06

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.

writeexcel does it wonderfully!

I think you should create blank Excel file with formulas and then fill it with Rails. Because you can't create formulas with Ruby.

There's a spreadsheet gem listed on RubyGems but having never used it I can't recommend it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!