[reportlab-users] Problem with row spanning in table

David Fraser reportlab-users@reportlab.com
Mon, 15 Sep 2003 14:36:56 +0200


This is a multi-part message in MIME format.
--------------040204080802040909000004
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hi

I am trying to debug a problem with row spanning.
The issue is, that if a cell spans two rows and covers all the columns 
in those rows, and if the rows are auto-sizing, they automatically size 
down to 0.
However, if the cell simply spans one row and covers all the columns, 
the row sizes to contain the cell.

I have attached a test case which demonstrates the problem (based on 
test-platypus-tables.py) and the (small!) pdf generated so people don't 
have to run it.
Each table has three rows and three columns. Rows are colored white, 
blue, red.
The first table has no cell spanning. This displays normally.
The second table has two sets of cell spanning, on the blue row and the 
red row.
The third table has one cell spanning over rows two and three, covering 
just the first two columns. This works fine..
The fourth table has one cell spanning over rows two and three, covering 
all columns. These rows are zero-height (the problem).
The fifth table is the same as the first, but has the row heights set to 
avoid the auto-size calculation ; it displays normally.

The reason I need the rows to auto-size is that the tables are generated 
automatically from data and so I do not want to have to estimate the 
size. A minimum height might be a work-around, but I hope there is some 
other solution.

David

PS I can dive into the reportlab code if neccessary so any pointers 
would be helpful

--------------040204080802040909000004
Content-Type: text/plain;
 name="test_platypus_tables_spanning.py"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="test_platypus_tables_spanning.py"

#!/bin/env python
#copyright ReportLab Inc. 2000
#see license.txt for license details
#history http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/reportlab/platypus/test/testtables.py?cvsroot=reportlab
#$Header: /cvsroot/reportlab/reportlab/test/test_platypus_tables.py,v 1.3 2002/07/24 19:56:38 andy_robinson Exp $
__version__=''' $Id: test_platypus_tables.py,v 1.3 2002/07/24 19:56:38 andy_robinson Exp $ '''
__doc__='Test script for reportlab.tables'

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(heights):
    t = Table((('a', 'full', 'row')
               ,('an empty row','A','B')
               ,('C','D','E')
              )
              ,rowHeights=heights
            )
    return t

def getstyles():
   styles = []
   for i in range(5):
       ts = [('ALIGN', (0,0), (-1,-1), 'LEFT')
             , ('VALIGN', (0,0), (-1,-1), 'MIDDLE') 
             , ('GRID', (0,0), (-1,-1), 0.25, colors.black)
             , ('BACKGROUND', (0,1), (1,2), colors.blue)
             , ('BACKGROUND', (1,1), (2,2), colors.red) ]
       if i == 1:
            ts.append(('SPAN', (0,1), (2,1)))
            ts.append(('SPAN', (1,1), (2,2)))
       if i == 2:
            ts.append(('SPAN', (0,1), (1,2)))
       if i == 3:
            ts.append(('SPAN', (0,1), (2,2)))
       if i == 4:
            ts.append(('SPAN', (0,1), (2,2)))
       styles.append(TableStyle(ts))
   return styles
       
def run():
    doc = SimpleDocTemplate('test_platypus_tables_spanning.pdf', pagesize=(8.5*inch, 11*inch), showBoundary=1)
    lst = []
    styles = getstyles()
    for i in range(len(styles)):
        style = styles[i]
        if i == 4:
            t = getTable([16,16,16])
        else:
            t = getTable([None,None,None])
        t.setStyle(style)
        lst.append(t)
        lst.append(Spacer(0,12))
    doc.build(lst)


class TablesTestCase(unittest.TestCase):
    "Make documents with tables"

    def test0(self):
        "Make a document full of tables"
        run()


def makeSuite():
    return makeSuiteForClasses(TablesTestCase)


#noruntests
if __name__ == "__main__":
    unittest.TextTestRunner().run(makeSuite())



--------------040204080802040909000004
Content-Type: application/pdf;
 name="test_platypus_tables_spanning.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
 filename="test_platypus_tables_spanning.pdf"

JVBERi0xLjMNCiWTjIueIFJlcG9ydExhYiBHZW5lcmF0ZWQgUERGIGRvY3VtZW50IGh0dHA6
Ly93d3cucmVwb3J0bGFiLmNvbQ0KJSAnQmFzaWNGb250cyc6IGNsYXNzIFBERkRpY3Rpb25h
cnkgDQoxIDAgb2JqDQolIFRoZSBzdGFuZGFyZCBmb250cyBkaWN0aW9uYXJ5DQ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