# XML/Excel export?

**URL:** <https://www.ruby-forum.com/t/xml-excel-export/148619>\
**Category:** Rails\
**Created:** [September 15, 2008, 5:00pm UTC](https://www.ruby-forum.com/t/xml-excel-export/148619 "2008-09-15T17:00:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/6de8d8/32.png) [@nik](https://www.ruby-forum.com/u/nik)\
**Post date:** [September 15, 2008, 5:00pm UTC](https://www.ruby-forum.com/t/xml-excel-export/148619/1 "2008-09-15T17:00:41Z")

</div>

Good morning, all!

Can anyone point me to the direction of creating a link that leads to  
the downloading of a rails generated XML file. I have an app and a  
database both called catalog, and I have  
a controller called store, and a model called product. The database  
has a products table with a handful of manually input product items.

The controller is quite plain with an index and a @products =  
Product.find(:all)

How may I create a button or link that leads to the generating of an  
XML file and one to Excel (is it possible? I mean, copyright and  
loyalty to MS a concern?). And how can I make it so that after  
clicking this link or button or both, the browser prompts for a  
download instead of displaying it on itself like Firefox and Internet  
Explorer do. Google Chrome just displays it in one line, I haven’t  
checked Safari yet.

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![nik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/6de8d8/32.png) [@nik](https://www.ruby-forum.com/u/nik)\
**Post date:** [September 15, 2008, 8:53pm UTC](https://www.ruby-forum.com/t/xml-excel-export/148619/2 "2008-09-15T20:53:13Z")

</div>

I’ve used the tutorial at the top with great success the last couple  
of weeks.

[http://wiki.rubyonrails.org/rails/pages/HowToExportToExcel](http://wiki.rubyonrails.org/rails/pages/HowToExportToExcel)

---

<div class="post-metadata">

**Author:** ![nik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/6de8d8/32.png) [@nik](https://www.ruby-forum.com/u/nik)\
**Post date:** [September 17, 2008, 4:34am UTC](https://www.ruby-forum.com/t/xml-excel-export/148619/3 "2008-09-17T04:34:48Z")

</div>

Thank You for both of your suggestions. Let me try it out.

RobL, how does one format an XML file? I am sorry to trouble you if  
this seems very elementary which I wouldn’t suspect otherwise. Because  
I thought XML is always just a bunch of structured data and Firefox is  
the one that formats it and displays it.

Or do you mean, I giving the data the structure I want in that  
rxml.erb file?

Thank You!

---

<div class="post-metadata">

**Author:** ![nik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/6de8d8/32.png) [@nik](https://www.ruby-forum.com/u/nik)\
**Post date:** [September 16, 2008, 12:46pm UTC](https://www.ruby-forum.com/t/xml-excel-export/148619/4 "2008-09-16T12:46:19Z")

</div>

Hey there,

Presumably you have a ProductsController, if you have a route for your  
Products resource Rails should cope with a request for

[http://localhost:3000/products.xml](http://localhost:3000/products.xml)

./config/routes.rb  
map.resources :products

you then write a view and format the XML as you’d like it to appear in  
the following view file  
./app/views/products/index.rxml.erb

RobL
