[reportlab-users] Table instance has no attribute '_rowpositions'

Robin Becker robin at reportlab.com
Tue Feb 15 04:06:26 EST 2005


rptl at s.rhythm.cx wrote:
> Hi everyone. I'm new to reportlab - it looks pretty neat. I'm having a
> problem with one of my initial experiments. I'm trying to put a simple
> table onto a page with this code:
> 
> 	from reportlab.pdfgen import canvas
> 	from reportlab.platypus import Table
> 	
> 	data = [['ul','ur'],['ll','lr']]
> 	t=Table(data)
> 	
> 	c = canvas.Canvas("hello.pdf")
> 	
> 	t.drawOn(c,200,100)
> 	
> 	c.showPage()
> 	c.save()
> 
> However, the following exception is thrown up from the guts of reportlab and
> doesn't mean too much to me:
> 
> 	Traceback (most recent call last):
> 	  File "./pr.py", line 11, in ?
> 	    t.drawOn(c,200,100) File
> 	  "/usr/lib/python2.3/site-packages/reportlab/platypus/flowables.py",
> 	line97, in drawOn
> 	    self._drawOn(canvas) File
> 	  "/usr/lib/python2.3/site-packages/reportlab/platypus/flowables.py",
> 	line82, in _drawOn
> 	    self.draw()#this is the bit you overload File
> 	  "/usr/lib/python2.3/site-packages/reportlab/platypus/tables.py",
> 	    line 951, in draw for row, rowstyle, rowpos, rowheight in
> 	    map(None, self._cellvalues,
> 	self._cellStyles, self._rowpositions[1:], self._rowHeights):
> 	AttributeError: Table instance has no attribute '_rowpositions'
> 
> Can anyone explain what's wrong?
> 
> Thanks
.....

You need to supply rowheights & colwidths or call the wrapOn method that 
attempts to calculate widths and heights etc. You need to supply 
dimensions eg

w,h = t.wrapOn(c,3*72,2*72)

allows for width 3*72 height 2*72.
-- 
Robin Becker


More information about the reportlab-users mailing list