[reportlab-users] wordwraps in tablecells

Wietse Jacobs wietse.j at gmail.com
Thu Sep 25 09:26:56 EDT 2008


2008/9/25 steven Van de Weyer <vandeweyer.s at gmail.com>:

> Just started using reportlab to generate some reports. And am new to python

> (and PyQT) as well

>

> What happens: I set my table column width manually. I get data from SQLite

> to bind with the table cells. Expected to have the string wrapped and the

> rowheight adjusted, but seems my data is shown across multiple columns on

> the same line.

>

> I checked the mailing list for solutions, but didn't quiet find what I was

> looking for. Even for this kind of a noob question.

>

> This is how I initialise my table

>

> t = Table(resvancache,(50,150,150,150,50),None,TableStyle([('INNERGRID',

> (0,0), (-1,-1), 0.25, colors.black),

> ('BOX', (0,0), (-1,-1), 0.25, colors.black),

> ('VALIGN',(0,0),(-1,-1),'MIDDLE'),

> ('ALIGN',(0,0),(-1,-1),'RIGHT'),

> ('TEXTCOLOR',(-1,0),(-1,-1),colors.red)]),1)

>

> Is there something I have overlooked? Thanks in advance.


Instead of passing the raw data you can wrap the cell data in a
`Paragraph`, something like:

table_data = [[Paragraph(col, my_style) for col in row] for row in sql_data]

--
--Wietse - also in Belgium ;-)


More information about the reportlab-users mailing list