# How to export data

**URL:** <https://www.ruby-forum.com/t/how-to-export-data/96480>\
**Category:** Rails\
**Created:** [June 28, 2006, 11:58pm UTC](https://www.ruby-forum.com/t/how-to-export-data/96480 "2006-06-28T23:58:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lunamaria](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d78d45/32.png) [@lunamaria](https://www.ruby-forum.com/u/lunamaria)\
**Post date:** [June 28, 2006, 11:58pm UTC](https://www.ruby-forum.com/t/how-to-export-data/96480/1 "2006-06-28T23:58:24Z")

</div>

Hello

I would like to know if there is a webpage or something else (even  
another thread in this forum) where there’s an explanation (preferably  
simple and detailed)on how to export data from a rail application to a  
.doc or a .xls. I have read Agile Web, Rails recipes and a few threads  
in this forum but I don’t know how to do it.  
Where is stored the model document ? How to choose the data to export ?  
I will read a bit more about send data or CSV, but these are quite  
unknown to me.

Thanks for the reply.

---

<div class="post-metadata">

**Author:** ![lunamaria](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d78d45/32.png) [@lunamaria](https://www.ruby-forum.com/u/lunamaria)\
**Post date:** [June 29, 2006, 12:02am UTC](https://www.ruby-forum.com/t/how-to-export-data/96480/2 "2006-06-29T00:02:14Z")

</div>

Please do not send unsolicited mail to wku.edu email accounts. If you  
feel that your message was rejected in error please contact 270-745-7000

---

<div class="post-metadata">

**Author:** ![lunamaria](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d78d45/32.png) [@lunamaria](https://www.ruby-forum.com/u/lunamaria)\
**Post date:** [June 29, 2006, 12:21am UTC](https://www.ruby-forum.com/t/how-to-export-data/96480/3 "2006-06-29T00:21:17Z")

</div>

On Wed, 2006-06-28 at 23:58 +0200, ClÃ©lia Nev wrote:

> Hello
> 
> I would like to know if there is a webpage or something else (even  
> another thread in this forum) where there’s an explanation (preferably  
> simple and detailed)on how to export data from a rail application to a  
> .doc or a .xls. I have read Agile Web, Rails recipes and a few threads  
> in this forum but I don’t know how to do it.  
> Where is stored the model document ? How to choose the data to export ?  
> I will read a bit more about send data or CSV, but these are quite  
> unknown to me.

* * *

I found it easiest to completely sidestep the issue and incorporated the  
following two lines of code in a controller…

```
mytext = render :action => 'client_list_all_export'
send_data mytext, :type => 'application/vnd.ms-excel', :disposition

```

=\> ‘inline’

which ultimately opened an excel spreadsheet with the data/format of my  
‘client\_list\_all\_export.rhtml’ view file directly - it was so cool that  
I almost fell out of my chair.

YMMV

Craig

---

<div class="post-metadata">

**Author:** ![lunamaria](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d78d45/32.png) [@lunamaria](https://www.ruby-forum.com/u/lunamaria)\
**Post date:** [June 29, 2006, 3:12am UTC](https://www.ruby-forum.com/t/how-to-export-data/96480/4 "2006-06-29T03:12:40Z")

</div>

> I found it easiest to completely sidestep the issue and incorporated the  
> following two lines of code in a controller…
> 
> ```
> mytext = render :action => 'client_list_all_export'
> send_data mytext, :type => 'application/vnd.ms-excel', :disposition
> 
> ```
> 
> =\> ‘inline’
> 
> which ultimately opened an excel spreadsheet with the data/format of my  
> ‘client\_list\_all\_export.rhtml’ view file directly - it was so cool that  
> I almost fell out of my chair.
> 
> YMMV
> 
> Craig

Thanks, I have tried this way just now, and it seemed to work quite  
fine. Since I don’t want to spend hours thinking about another way, I’ll  
stick with this method.

Thanks a lot,  
ClÃ©lia

---

<div class="post-metadata">

**Author:** ![lunamaria](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d78d45/32.png) [@lunamaria](https://www.ruby-forum.com/u/lunamaria)\
**Post date:** [June 29, 2006, 3:15am UTC](https://www.ruby-forum.com/t/how-to-export-data/96480/5 "2006-06-29T03:15:21Z")

</div>

Please do not send unsolicited mail to wku.edu email accounts. If you  
feel that your message was rejected in error please contact 270-745-7000
