Hi Everyone..

I need to generate the Excel Sheet through the Ruby On Rails.I have to create the excel sheet with the database fields as headers and the data in the sheet

I installed the required gems…

gem install spreadsheet-excel -v = 0.3.5.1

and i worte the code as

wb = Spreadsheet::Excel.new(“E:/RailsApps/application/sample.xls”)
version = Excel::VERSION

f4 = Format.new(:num_format => “d mmm yyyy”)
f5 = Format.new(:num_format => 0x0f)
wb.add_format(f4)
wb.add_format(f5)

**ws1 = wb.add_worksheet(“employee”)
header = [‘ID’,‘Name’,‘Designation’,‘Salary’,‘JoinDate’]
len = header.length - 1
for k in 0…len do
puts “Header of K #{header[k]}”
ws1.write(0,k,header[k],f1)
end