Import Excel into Rails app

时光总嘲笑我的痴心妄想 提交于 2019-12-02 15:34:26
clyfe

"The Spreadsheet Library is designed to read and write Spreadsheet Documents. As of version 0.6.0, only Microsoft Excel compatible spreadsheets are supported. Spreadsheet is a combination/complete rewrite of the Spreadsheet::Excel Library by Daniel J. Berger and the ParseExcel Library by Hannes Wyss. Spreadsheet can read, write and modify Spreadsheet Documents."

EDIT
To get the uploaded file you have two options:
1. (recommended) Use something a file upload plugin like paperclip and it will handle the bits and bolts.
2. use the IO object params[:dump][:excel_file] as per: http://guides.rails.info/form_helpers.html#what-gets-uploaded

allenwei

we use roo which support Open Office,Excel,Google,Excel.xlsx

There's an excellent RailsCast on how to do this with the roo gem: http://railscasts.com/episodes/396-importing-csv-and-excel

Hey I use the spreadsheet gem and wrote a simple app to understand how it all fits together. It currently runs on Rails 3.1 and Carrierwave, hope this helps:

https://github.com/jalagrange/excel_test_app

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