[reportlab-users] How to delete added TableStyles

Björn Platzen reportlab-users@reportlab.com
Fri, 12 Jul 2002 10:22:46 +0200


> > This works fine until I have one table, because when I process the next
> > table, all the added Styles are still there and do not fit my second
> > table...
> >
> > Is there any way to delete these added styles???
>
> I don't see what you mean. Are you sure you create new styles
> for your next table from scratch? If you don't, then why not?

I'm processing xml-files that sometimes contain more than one table. All 
tables use the same style.  For each table some alignments for a single cell 
are added to the stylesheet. This happens during one runtime of PythonPoint. 

Here is the output of a runtime:

TableStyle(
('FONT', (0, 0), (-1, -1), 'Helvetica', 10)  
('BOX', (0, 0), (-1, -1), 1, Color(0.00,0.00,0.00))  
('INNERGRID', (0, 0), (-1, -1), 1, Color(0.00,0.00,0.00))  
('ALIGN', (1, 0), (-1, -1), 'RIGHT')  
('VALIGN', (0, 0), (-1, -1), 'MIDDLE')  
('TEXTCOLOR', (0, 0), (-1, -1), Color(0.00,0.00,0.00))  
('BOTTOMPADDING', (0, 0), (-1, -1), 1)  
('TOPPADDING', (0, 0), (-1, -1), 5)  
('LEFTPADDING', (0, 0), (-1, -1), 1)  
('RIGHTPADDING', (0, 0), (-1, -1), 1)  
('ALIGN', (0, 0), (0, 0), 'LEFT')  
('ALIGN', (4, 0), (4, 0), 'LEFT')  
('ALIGN', (0, 1), (0, 1), 'LEFT')  
('ALIGN', (0, 2), (0, 2), 'LEFT')  
('ALIGN', (0, 3), (0, 3), 'LEFT')  
('ALIGN', (0, 4), (0, 4), 'LEFT')  
('ALIGN', (0, 5), (0, 5), 'LEFT')  
('ALIGN', (0, 6), (0, 6), 'LEFT')  
('ALIGN', (0, 7), (0, 7), 'LEFT')  
('ALIGN', (0, 8), (0, 8), 'LEFT')  
('ALIGN', (0, 9), (0, 9), 'LEFT')  
('ALIGN', (0, 10), (0, 10), 'LEFT')  
('ALIGN', (0, 11), (0, 11), 'LEFT')
) # end TableStyle
TableStyle(
('FONT', (0, 0), (-1, -1), 'Helvetica', 10)  
('BOX', (0, 0), (-1, -1), 1, Color(0.00,0.00,0.00))  
('INNERGRID', (0, 0), (-1, -1), 1, Color(0.00,0.00,0.00))  
('ALIGN', (1, 0), (-1, -1), 'RIGHT')  
('VALIGN', (0, 0), (-1, -1), 'MIDDLE')  
('TEXTCOLOR', (0, 0), (-1, -1), Color(0.00,0.00,0.00))  
('BOTTOMPADDING', (0, 0), (-1, -1), 1)  
('TOPPADDING', (0, 0), (-1, -1), 5)  
('LEFTPADDING', (0, 0), (-1, -1), 1)  
('RIGHTPADDING', (0, 0), (-1, -1), 1)  
('ALIGN', (0, 0), (0, 0), 'LEFT')  
('ALIGN', (4, 0), (4, 0), 'LEFT')  
('ALIGN', (0, 1), (0, 1), 'LEFT')  
('ALIGN', (0, 2), (0, 2), 'LEFT')  
('ALIGN', (0, 3), (0, 3), 'LEFT')  
('ALIGN', (0, 4), (0, 4), 'LEFT')  
('ALIGN', (0, 5), (0, 5), 'LEFT')  
('ALIGN', (0, 6), (0, 6), 'LEFT')  
('ALIGN', (0, 7), (0, 7), 'LEFT')  
('ALIGN', (0, 8), (0, 8), 'LEFT')  
('ALIGN', (0, 9), (0, 9), 'LEFT')  
('ALIGN', (0, 10), (0, 10), 'LEFT')  
('ALIGN', (0, 11), (0, 11), 'LEFT')  
('ALIGN', (0, 0), (0, 0), 'LEFT')  
('ALIGN', (0, 1), (0, 1), 'LEFT')  
('ALIGN', (0, 2), (0, 2), 'LEFT')  
('ALIGN', (0, 3), (0, 3), 'LEFT')  
('ALIGN', (0, 4), (0, 4), 'LEFT')  
('ALIGN', (0, 5), (0, 5), 'LEFT')  
('ALIGN', (0, 6), (0, 6), 'LEFT')  
('ALIGN', (0, 7), (0, 7), 'LEFT')  
('ALIGN', (0, 8), (0, 8), 'LEFT')  
('ALIGN', (0, 9), (0, 9), 'LEFT')  
('ALIGN', (0, 10), (0, 10), 'LEFT')  
('ALIGN', (0, 11), (0, 11), 'LEFT')
) # end TableStyle
TableStyle(
('FONT', (0, 0), (-1, -1), 'Helvetica', 10)  
('BOX', (0, 0), (-1, -1), 1, Color(0.00,0.00,0.00))  
('INNERGRID', (0, 0), (-1, -1), 1, Color(0.00,0.00,0.00))  
('ALIGN', (1, 0), (-1, -1), 'RIGHT')  
('VALIGN', (0, 0), (-1, -1), 'MIDDLE')  
('TEXTCOLOR', (0, 0), (-1, -1), Color(0.00,0.00,0.00))  
('BOTTOMPADDING', (0, 0), (-1, -1), 1)  
('TOPPADDING', (0, 0), (-1, -1), 5)  
('LEFTPADDING', (0, 0), (-1, -1), 1)  
('RIGHTPADDING', (0, 0), (-1, -1), 1)  
('ALIGN', (0, 0), (0, 0), 'LEFT')  
('ALIGN', (4, 0), (4, 0), 'LEFT')  
('ALIGN', (0, 1), (0, 1), 'LEFT')  
('ALIGN', (0, 2), (0, 2), 'LEFT')  
('ALIGN', (0, 3), (0, 3), 'LEFT')  
('ALIGN', (0, 4), (0, 4), 'LEFT')  
('ALIGN', (0, 5), (0, 5), 'LEFT')  
('ALIGN', (0, 6), (0, 6), 'LEFT')  
('ALIGN', (0, 7), (0, 7), 'LEFT')  
('ALIGN', (0, 8), (0, 8), 'LEFT')  
('ALIGN', (0, 9), (0, 9), 'LEFT')  
('ALIGN', (0, 10), (0, 10), 'LEFT')  
('ALIGN', (0, 11), (0, 11), 'LEFT')  
('ALIGN', (0, 0), (0, 0), 'LEFT')  
('ALIGN', (0, 1), (0, 1), 'LEFT')  
('ALIGN', (0, 2), (0, 2), 'LEFT')  
('ALIGN', (0, 3), (0, 3), 'LEFT')  
('ALIGN', (0, 4), (0, 4), 'LEFT')  
('ALIGN', (0, 5), (0, 5), 'LEFT')  
('ALIGN', (0, 6), (0, 6), 'LEFT')  
('ALIGN', (0, 7), (0, 7), 'LEFT')  
('ALIGN', (0, 8), (0, 8), 'LEFT')  
('ALIGN', (0, 9), (0, 9), 'LEFT')  
('ALIGN', (0, 10), (0, 10), 'LEFT')  
('ALIGN', (0, 11), (0, 11), 'LEFT')  
('ALIGN', (0, 0), (0, 0), 'LEFT')  
('ALIGN', (0, 1), (0, 1), 'LEFT')  
('ALIGN', (0, 2), (0, 2), 'LEFT')  
('ALIGN', (0, 3), (0, 3), 'LEFT')  
('ALIGN', (0, 4), (0, 4), 'LEFT')  
('ALIGN', (0, 5), (0, 5), 'LEFT')  
('ALIGN', (0, 6), (0, 6), 'LEFT')  
('ALIGN', (0, 7), (0, 7), 'LEFT')  
('ALIGN', (0, 8), (0, 8), 'LEFT')  
('ALIGN', (4, 8), (4, 8), 'LEFT')  
('ALIGN', (0, 9), (0, 9), 'LEFT')  
('ALIGN', (0, 10), (0, 10), 'LEFT')  
('ALIGN', (0, 11), (0, 11), 'LEFT')
) # end TableStyle
TableStyle(
('FONT', (0, 0), (-1, -1), 'Helvetica', 10)  
('BOX', (0, 0), (-1, -1), 1, Color(0.00,0.00,0.00))  
('INNERGRID', (0, 0), (-1, -1), 1, Color(0.00,0.00,0.00))  
('ALIGN', (1, 0), (-1, -1), 'RIGHT')  
('VALIGN', (0, 0), (-1, -1), 'MIDDLE')  
('TEXTCOLOR', (0, 0), (-1, -1), Color(0.00,0.00,0.00))  
('BOTTOMPADDING', (0, 0), (-1, -1), 1)  
('TOPPADDING', (0, 0), (-1, -1), 5)  
('LEFTPADDING', (0, 0), (-1, -1), 1)  
('RIGHTPADDING', (0, 0), (-1, -1), 1)  
('ALIGN', (0, 0), (0, 0), 'LEFT')  
('ALIGN', (4, 0), (4, 0), 'LEFT')  
('ALIGN', (0, 1), (0, 1), 'LEFT')  
('ALIGN', (0, 2), (0, 2), 'LEFT')  
('ALIGN', (0, 3), (0, 3), 'LEFT')  
('ALIGN', (0, 4), (0, 4), 'LEFT')  
('ALIGN', (0, 5), (0, 5), 'LEFT')  
('ALIGN', (0, 6), (0, 6), 'LEFT')  
('ALIGN', (0, 7), (0, 7), 'LEFT')  
('ALIGN', (0, 8), (0, 8), 'LEFT')  
('ALIGN', (0, 9), (0, 9), 'LEFT')  
('ALIGN', (0, 10), (0, 10), 'LEFT')  
('ALIGN', (0, 11), (0, 11), 'LEFT')  
('ALIGN', (0, 0), (0, 0), 'LEFT')  
('ALIGN', (0, 1), (0, 1), 'LEFT')  
('ALIGN', (0, 2), (0, 2), 'LEFT')  
('ALIGN', (0, 3), (0, 3), 'LEFT')  
('ALIGN', (0, 4), (0, 4), 'LEFT')  
('ALIGN', (0, 5), (0, 5), 'LEFT')  
('ALIGN', (0, 6), (0, 6), 'LEFT')  
('ALIGN', (0, 7), (0, 7), 'LEFT')  
('ALIGN', (0, 8), (0, 8), 'LEFT')  
('ALIGN', (0, 9), (0, 9), 'LEFT')  
('ALIGN', (0, 10), (0, 10), 'LEFT')  
('ALIGN', (0, 11), (0, 11), 'LEFT')  
('ALIGN', (0, 0), (0, 0), 'LEFT')  
('ALIGN', (0, 1), (0, 1), 'LEFT')  
('ALIGN', (0, 2), (0, 2), 'LEFT')  
('ALIGN', (0, 3), (0, 3), 'LEFT')  
('ALIGN', (0, 4), (0, 4), 'LEFT')  
('ALIGN', (0, 5), (0, 5), 'LEFT')  
('ALIGN', (0, 6), (0, 6), 'LEFT')  
('ALIGN', (0, 7), (0, 7), 'LEFT')  
('ALIGN', (0, 8), (0, 8), 'LEFT')  
('ALIGN', (4, 8), (4, 8), 'LEFT')  
('ALIGN', (0, 9), (0, 9), 'LEFT')  
('ALIGN', (0, 10), (0, 10), 'LEFT')  
('ALIGN', (0, 11), (0, 11), 'LEFT')  
('ALIGN', (0, 0), (0, 0), 'LEFT')  
('ALIGN', (0, 1), (0, 1), 'LEFT')  
('ALIGN', (0, 2), (0, 2), 'LEFT')  
('ALIGN', (0, 3), (0, 3), 'LEFT')  
('ALIGN', (0, 4), (0, 4), 'LEFT')  
('ALIGN', (4, 4), (4, 4), 'LEFT')  
('ALIGN', (0, 5), (0, 5), 'LEFT')  
('ALIGN', (4, 5), (4, 5), 'LEFT')
) # end TableStyle


In this special case I've got the Problem, that the fourth table has just 8 
lines and not 11 like the others. So I get

File "/usr/lib/python2.0/reportlab/platypus/tables.py", line 621, in 
_setCellStyle
    new = cellStyles[i][j]
IndexError: list index out of range

Somehow I will have to clean up the TableStyle before I process the next 
table during the runtime, to be sure that the style doesn't contain any wrong 
cell-indexes.



> Have you tested this outside PythonPoint, too?

not yet...


Bjoern


>
> Dinu

------------------------------------------------------------
small office solutions - Lösungen für das Internet

www.sosnetz.de - info@sosnetz.de - 0700-SOSPHONE

Office Krefeld:
Postfach 100 427 - 47704 Krefeld
Fon 0 21 51 / 3 19 45-50 Fax 0 21 51 / 3 19 45-31

Office Moers:
In der Dong 29 - 47445 Moers
Fon 0 28 41 / 88 64 - 41 Fax 0 28 41 / 88 64 -42