[reportlab-users] Newby-question: Cannot initialize Table-objects

Joost Behrends webmaster at h-labahn.de
Fri Feb 15 22:00:47 EST 2008


Hi,

i will use reportlab in our small enterprise
dealing historical picture postcards. A lot
of work is done with my software - that means
i need a lot of tables.

The code of that software is fully portable and shall stay so.
I'd strongly like to make all printing (including
invoices etc. as e-mail attachments) through reportlab.
end enjoyed my first experiences with the canvas.
Everything worked from the first moment on -
and exactly as described in the documentation. Seems
to be great software - thanks for that.

But getting to tables, i do not get them
initialized correctly. Here is a very reduced
example for isolating the problem:

from reportlab.pdfgen import canvas
from reportlab.platypus import Table

atb = (('Hamburg', 'Germany', '1,760,322'),
('Paris', 'France', '9,644,507'),
('London', 'England', '8.278.251'))

def drawTb(larg):
cnv = canvas.Canvas('C:\\tmp\\tb.pdf',
pagesize = (595.27, 841.89))
tbOnPage = Table(larg)
tbOnPage.drawOn(cnv, 0, 0)
cnv.showPage()
cnv.save()
drawTb(atb)

This produces:


>>> execfile('exampleTable.py')

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "exampleTable.py", line 18, in <module>
drawTb(atb)
File "exampleTable.py", line 14, in drawTb
tbOnPage.drawOn(cnv, 0, 0)
File "C:\Programme\Python25\reportlab\platypus\flowables.py",
line 102, in drawOn
self._drawOn(canvas)
File "C:\Programme\Python25\reportlab\platypus\flowables.py",
line 86, in _drawOn
self.draw()#this is the bit you overload
File "C:\Programme\Python25\reportlab\platypus\tables.py",
line 1160, 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'

Versions with more imports (SimpleDocTemplate)
do not work either. Nor did setting the rowHeights
argument. Where do i fail ?

Thanks, Joost



More information about the reportlab-users mailing list