See my plugin:
http://www.napcsweb.com/blog/2006/02/10/excel-plugin-10/
Pretty easy to use actually.
def export_project_to_excel
e = Excel::Workbook
@project = Project.find(:all)
@tasks = @project.tasks
# ActiveRecord worksheets need a tab name, the object type, and the collection
e.addWorksheetFromActiveRecord "Project", "project",
@project
e.addWorksheetFromActiveRecord "Tasks", "task", @tasks
headers[''Content-Type''] =
"application/vnd.ms-excel"
render_text(e.build)
end
or the advanced mode
def export_book_info_to_excel
books = Book.find(:all)
my_array = Array.new
for book in books
item = Hash.new
item["Title"] = book.title
item["ISBN"] = book.isbn
item["Author"] = book.author.last_name
item["Category"] = book.category.name
item["Total Sales"] = book.sales.size
my_array << item
end
addWorksheetFromArrayOfHashes("Books info", my_array)
headers[''Content-Type''] =
"application/vnd.ms-excel"
render_text(e.build)
end
On 8/7/06, ribit <mcse@palstek.ch> wrote:>
> Can anyone help me ???
>
> I want to export some data into MS excel and create a pie or line chart.
> How can I export the data? Does it gives any tutorial websites ?
>
> thanks for your help!
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060807/3eb74bd7/attachment.html