[reportlab-users] Tables and spanning

Johan Paul Glutting reportlab-users@reportlab.com
Thu, 30 Sep 2004 10:40:45 +0200


NewUpdate:

In the original code, I was making a deepcopy of an existing class that 
I had been using, and then modifying that to do spanning. Spanning works 
more or less correctly if I create a new format instance using 
TableStyle. Unnervingly, though, it overwrites the text in the spanned 
cells, but does not supress it - I can just make the overwritten cells 
empty, but I am not sure whay this happens.

Also, it is applying formatting to all the cells individually - the text 
("-- ") in the "empty" cells in centered within that one cell, whicle 
the spanned text is centered across the cell span.

Here is the basic code:

    tdata = 
[['Cicle','Curs','Codi','Assignatures','Tipus\n(T,B,O)','Crèdits','--','Matriculats','','Nombre 
de\ngrups','--','--','Nombre 
de\nprofessors','--','--','Professors\ndiferents'],
    ['--','--','--','--','--', 'T','PA','Total','1r 
mat.','T','PA','PL','T','PA','PL','--'],]
    NewTabStyle = TableStyle()
    NewTabStyle.add('SPAN', (5,0),(6,0))
    NewTabStyle.add('SPAN', (7,0),(8,0))
    NewTabStyle.add('SPAN', (10,0),(12,0))
    NewTabStyle.add('SPAN', (13,0),(15,0))
    NewTabStyle.add('ALIGN', (0,0), (-1,1), 'CENTER')
    NewTabStyle.add('INNERGRID', (0,0), (-1,-1), 0.25, rlclass.colors.grey)
    t = Table(data, style=NewTabStyle)
    t.hAlign = 'CENTER'
    r.Elements.append(t)

"r" is a class that generates a SimpleDocTemplate using the Elements 
property (a list...) like this:

        doc = SimpleDocTemplate(self.fname, pagesize=A4)
        doc.build(self.Elements,onFirstPage=self.myFirstPage, 
onLaterPages=self.myLaterPages)


This creates a table that spans the 5-6 and 7-8 cells correctly, but 
does no apparent spanning, and strange deletions, in the rest of the 
cells (it deletes the contents of the cells 10, 12 and 13 in the first row).

Unfortunately, nearly identical code in the "production" function 
produces very different results - it appears that cells 4-8, 11-13, and 
14-15 are merged, but all the text is strung together and nothing is 
eliminated. It is possible that the width of the table, which is a bit 
big, is causing some problems, but that is unclear as well....

I will send you the output document as an attachment.

The version I am using is 1.19 (I misread the __init__.py file)

Cheers,

JP

-- 

JP Glutting
Oficina de Qualitat		Plaça Víctor Siurana, 1
Universitat de Lleida		25003 Lleida
-------------------------------------------------------
Tel: 973 703 103		Fax: 973 702 036