[reportlab-users] RE: table cell line breaking
Henning von Bargen
reportlab-users@reportlab.com
Mon, 29 Mar 2004 09:23:50 +0200
You can use Paragraphs (instead of plain text) as cell values.
But if a single word is too wide, it will still overflow to the next column
in the current version.
Henning
> Date: Sun, 28 Mar 2004 10:28:44 +0800 (CST)
> From:
=?gb2312?q?=FFffffca=FFffffbf=FFffffb7=FFffffbc=20=FFffffcd=FFfffff5?=
<wangshifang_2008@yahoo.com.cn>
> Subject: [reportlab-users] table
>
> Hi:
> the following is making the table, I specify the colwidth,
> the cell[2,3] is too long, how can I make it automatically go to next
line?
> not to modify the colwidth.
>
>
> from reportlab.test import unittest
> from reportlab.test.utils import makeSuiteForClasses
> from reportlab.platypus import Spacer, SimpleDocTemplate, Table,
TableStyle
> from reportlab.lib.units import inch
> from reportlab.lib import colors
> def getTable():
> data= [['A', 'B', 'C', 'dsdf'],
> ['00', '01', '02', 'df' ],
> ['10', '11', '12', 'sfasds fdfg sdg sdgf' ]]
> t=Table(data,style=[
> ('BOX',(0,0),(-1,-1),1,colors.black),
> ])
> t._argW[3]=0.3*inch
> return t
> def run():
> doc = SimpleDocTemplate('tables.pdf', pagesize=(8.5*inch, 11*inch),
showBoundary=0)
> lst = []
> t = getTable()
> lst.append(t)
> doc.build(lst)
> class TablesTestCase(unittest.TestCase):
> def test0(self):
> run()
> def makeSuite():
> return makeSuiteForClasses(TablesTestCase)
> if __name__ == "__main__":
> unittest.TextTestRunner().run(makeSuite())
>
> Thanks
>
>