rss
twitter
    Find out what I'm doing, Follow Me :)

How to export data using MS word or MS excel

Its also very easy to export data to doc format or xls format. There is no plugin or gem required for that.
The procedure is :

FOR XLS FORMAT:


def export
headers['Content-Type'] = "application/vnd.ms-excel"
headers['Content-Disposition'] = 'attachment; filename="excel-export.xls"'
headers['Cache-Control'] = ''
@records = Record.find(:all)
end


and

FOR DOC FORMAT


def export
headers['Content-Type'] = "application/vnd.ms-word"
headers['Content-Disposition'] = 'attachment; filename="excel-export.doc"'
headers['Cache-Control'] = ''
@records = Record.find(:all)
end

0 comments: