Posts

Showing posts from May, 2016

Simple way of importing and exporting excel, csv file for ruby on rails application using roo gem

Image
Create a Rails Application where student data can upload as excel and can be download as excel file. #Gemfile gem 'roo' #Student Table migration File class CreateStudents < ActiveRecord::Migration   def change     create_table :students do |t|         t.string :name         t.integer :roll_no         t.integer :marks1         t.integer :marks2         t.integer :marks3         t.integer :avg       t.timestamps null: false     end   end end #student_controller.rb class StudentController < ApplicationController   def s_home     @products = Student.all     respond_to do |format|       format.html       format.csv { send_data @products.to_csv }       format.xls { send_data @products.to_csv(col_sep: "\t"), filename: 'your...