[reportlab-users] got only 2 elements if i split the table

Lars Walther lwalther at novareto.de
Thu Oct 13 04:11:09 EDT 2011


Hi list

my Python-List of tabledata needs more than 2 A4 Pages and i want to print the data in a special frame on each page.

Now i try to split my table in several parts and after this using a "for i in splitter" construct to add the data in a frame on canvas.

The problem is, that i get only 2 elements after split and only the first element is fitting in my frame. At the moment i use a special "while" construct to split the 2nd element again and again.

Please tell me if i do a mistake or there is a better way to do my job.

Here is a part of my script to test the problem:

UBtable = Table(tabledata, colWidths=colWidths, style=[('GRID',(0,0),(-1,-1), 1, '#efefef'),])
tableframe = Frame(4*cm, 15*cm, 8*cm, 3*cm)

#Two Variants to split my table
splitter = tableframe.split(UBtable, c)
splitter1 = UBtable.split(8*cm, 3*cm)

#Result of split
print 'result of splitting variant-1:', len(splitter)
print 'result of splitting variant-2:', len(splitter1)

print 'Add tableparts to frame with variant-1'
for i in splitter:
tableframe = Frame(4*cm, 15*cm, 8*cm, 3*cm)
play = tableframe.add(i, c)
print 'result of adding table in frame 1=ok, 0=error:', play
c.showPage()

print 'Add tableparts to frame with variant-2'
for i in splitter1:
tableframe = Frame(4*cm, 15*cm, 8*cm, 3*cm)
play = tableframe.add(i, c)
print 'result of adding table in frame 1=ok, 0=error:', play
c.showPage()


Thanks for your answers
Lars



More information about the reportlab-users mailing list