[reportlab-users] Problem with spanned columns when a platypus table is split

Jean-Francois Gosset jfg at netinfo.fr
Wed Dec 22 08:39:55 EST 2004


Hi,

It seems that spanned commands are ignored when a table is split.
As seen in the output of the example, the first line of the first table is ok but is not spanned in the second print.

(I use reportlab 1.20).

Thanks for you help!
JF

######################################################################################
# -*- coding:ISO-8859-1 -*-
import reportlab.lib.colors as colors
import reportlab.lib.pagesizes
import reportlab.platypus 
from reportlab.lib.units import mm
from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY

doctemplate = reportlab.platypus.doctemplate.SimpleDocTemplate(
    filename = "test.pdf",
    showBoundary = 0,
    leftMargin = 15*mm,
    rightMargin = 15*mm,
    topMargin = 15*mm,
    bottomMargin =  15*mm,
    allowSplitting = 1)
    
NotUsed = "**NotUsed**"

spacer = reportlab.platypus.Spacer( 
    width = 0, 
    height = 15*mm)
        
story = []

for dummy in range(2) :
    data = [
        ["blah blah", NotUsed, NotUsed]]

    for ii in range(30) :
        data.append(
        ["%02i" % jj for jj in range(3)])

    table = reportlab.platypus.Table(
        data = data,
        colWidths =  [40*mm, 40*mm, 40*mm],
        rowHeights = [None for ii in range(len(data))])

    tableStyle = reportlab.platypus.TableStyle(
        cmds = [
            ('ALIGN', (0,0), (-1,-1), 'CENTER'),
            ('VALIGN', (0,0), (-1,0), 'TOP'),
            ('GRID', (0,0), (-1,-1), 0.5, colors.red),
            ('SPAN', (0,0), (-1,0))])

    table.setStyle(tblstyle = tableStyle)
    story.append(table)
    story.append(spacer)
    
doctemplate.build(
    flowables = story)
######################################################################################



More information about the reportlab-users mailing list