# Avoid trucate column at printing table

**URL:** <https://www.ruby-forum.com/t/avoid-trucate-column-at-printing-table/154462>\
**Category:** Ruby\
**Created:** [November 30, 2008, 12:28am UTC](https://www.ruby-forum.com/t/avoid-trucate-column-at-printing-table/154462 "2008-11-30T00:28:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mxp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3ab097/32.png) [@mxp](https://www.ruby-forum.com/u/mxp)\
**Post date:** [November 30, 2008, 12:28am UTC](https://www.ruby-forum.com/t/avoid-trucate-column-at-printing-table/154462/1 "2008-11-30T00:28:25Z")

</div>

Hi,

I’ve a table defined as the code below:

table = Table(%w[Page Position Domain URL Description])

And I fill it as you can see:

table \<\< [iPage, iPosition, sDomain, sURL, sDescription]

When I finish I want output the table doing this:

myfile.puts table.to\_s

but the content of the columns is too large and I get this:

±----------------------------------------------------------------------------\>\>  
| Page | Position | Domain | \>\>  
±----------------------------------------------------------------------------\>\>  
| 1 | 1 | [www.miltrabajos.com](http://www.miltrabajos.com) | [http://www.miltrabajos.com/Ofe](http://www.miltrabajos.com/Ofe)\>\>  
| 1 | 2 | [www.miltrabajos.com](http://www.miltrabajos.com) | [http://www.miltrabajos.com/CAM](http://www.miltrabajos.com/CAM)\>\>

How can I avoid the trucate of the table?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![mxp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3ab097/32.png) [@mxp](https://www.ruby-forum.com/u/mxp)\
**Post date:** [November 30, 2008, 5:51pm UTC](https://www.ruby-forum.com/t/avoid-trucate-column-at-printing-table/154462/2 "2008-11-30T17:51:13Z")

</div>

As a guess - because you don’t actually say it yourself - this is a  
question about the Ruport library, right?

I remember this being a bit of a pain to make do what I wanted.

(Digs through old code). Oh yes, in a custom Renderer you can do

options { |o| o.ignore\_table\_width = true }

However I’m not sure if it’s possible to this with the default renderer  
for a table (i.e. Table#to\_s as you’re doing above). Possibly you could  
fake the method which works out the screen size to give a much larger  
table width.

Ruport has its own google group - you’d probably be better off asking  
there.

HTH,

Brian.

---

<div class="post-metadata">

**Author:** ![mxp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3ab097/32.png) [@mxp](https://www.ruby-forum.com/u/mxp)\
**Post date:** [December 1, 2008, 10:45am UTC](https://www.ruby-forum.com/t/avoid-trucate-column-at-printing-table/154462/3 "2008-12-01T10:45:13Z")

</div>

Finally I’ve find the solution myself

I’m newbie with Ruby and Ruport. The solution is to call de “to\_text”  
method of the table instead of “to\_s” and use the “:ignore\_table\_width”  
attribute.

myfile.puts table.to\_text( :ignore\_table\_width =\> true, :width =\> 200)

I read this option in the documentation, but I didn’t known how to use  
it.

Now this works fine and produces this output:

±---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+  
| Page | Position | Domain | URL | Description |  
±---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+  
| 1 | 1 | [barcelona.campusanuncios.com](http://barcelona.campusanuncios.com) | [http://barcelona.campusanuncios.com/detempleo-1892452216X-Oferta-de-Barcelona.html](http://barcelona.campusanuncios.com/detempleo-1892452216X-Oferta-de-Barcelona.html) | Oferta de Empleo Primer empleo como programador Barcelona EspaðŸž |  
| 1 | 2 | empleo.trovit.es | [http://empleo.trovit.es/ofertas-empleo/programador-php-barcelona](http://empleo.trovit.es/ofertas-empleo/programador-php-barcelona) | programador php barcelona - Trovit Empleo |
