reportlab/test/test_platypus_tables.py
author rgbecker
Fri, 26 Oct 2007 16:16:38 +0000
changeset 2878 a7af19b6f9fb
parent 2819 0af8d3e7dfc9
child 2879 0ba5481218bd
permissions -rw-r--r--
reportlab: fix cell spanning bug in tables.py (from Volker Haas)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
857
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
     1
#!/bin/env python
2332
2a7ab4405e18 Remove $Header:, fix CopyRight & history
rgbecker
parents: 2268
diff changeset
     2
#Copyright ReportLab Europe Ltd. 2000-2004
857
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
     3
#see license.txt for license details
2332
2a7ab4405e18 Remove $Header:, fix CopyRight & history
rgbecker
parents: 2268
diff changeset
     4
#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/test/test_platypus_tables.py
2a7ab4405e18 Remove $Header:, fix CopyRight & history
rgbecker
parents: 2268
diff changeset
     5
__version__=''' $Id$ '''
857
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
     6
__doc__='Test script for reportlab.tables'
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
     7
1667
dfe2f821f4e2 Slightly refactored test suite to do the same thing with less code.
dinu_gherman
parents: 857
diff changeset
     8
from reportlab.test import unittest
2505
0859d48c2558 reportlab/test: fix so individual tests print output folder location
rgbecker
parents: 2475
diff changeset
     9
from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
857
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    10
from reportlab.platypus import Spacer, SimpleDocTemplate, Table, TableStyle
2384
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    11
from reportlab.lib.units import inch, cm
857
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    12
from reportlab.lib import colors
1667
dfe2f821f4e2 Slightly refactored test suite to do the same thing with less code.
dinu_gherman
parents: 857
diff changeset
    13
857
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    14
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    15
def getTable():
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    16
    t = Table((('','North','South','East','West'),
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    17
             ('Quarter 1',100,200,300,400),
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    18
             ('Quarter 2',100,400,600,800),
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    19
             ('Total',300,600,900,'1,200')),
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    20
             (72,36,36,36,36),
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    21
             (24, 16,16,18)
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    22
            )
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    23
    return t
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    24
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    25
def makeStyles():
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    26
    styles = []
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    27
    for i in range(5):
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    28
        styles.append(TableStyle([('ALIGN', (1,1), (-1,-1), 'RIGHT'),
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2505
diff changeset
    29
                                  ('ALIGN', (0,0), (-1,0), 'CENTRE'),
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2505
diff changeset
    30
                                  ('HREF', (0,0), (0,0), 'www.google.com'),
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2505
diff changeset
    31
                                  ]))
857
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    32
    for style in styles[1:]:
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    33
        style.add('GRID', (0,0), (-1,-1), 0.25, colors.black)
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    34
    for style in styles[2:]:
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    35
        style.add('LINEBELOW', (0,0), (-1,0), 2, colors.black)
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    36
    for style in styles[3:]:
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    37
        style.add('LINEABOVE', (0, -1), (-1,-1), 2, colors.black)
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    38
    styles[-1].add('LINEBELOW',(1,-1), (-1, -1), 2, (0.5, 0.5, 0.5))
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    39
    return styles
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    40
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    41
def run():
2268
a51a4b6873c8 Move to having all test output in a temp folder
rgbecker
parents: 1683
diff changeset
    42
    doc = SimpleDocTemplate(outputfile('test_platypus_tables.pdf'), pagesize=(8.5*inch, 11*inch), showBoundary=1)
857
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    43
    styles = makeStyles()
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    44
    lst = []
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    45
    for style in styles:
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    46
        t = getTable()
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    47
        t.setStyle(style)
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    48
##        print '--------------'
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    49
##        for rowstyle in t._cellstyles:
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    50
##            for s in rowstyle:
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    51
##                print s.alignment
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    52
        lst.append(t)
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    53
        lst.append(Spacer(0,12))
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    54
    doc.build(lst)
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
    55
2384
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    56
def old_tables_test():
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    57
    from reportlab.lib.units import inch, cm
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    58
    from reportlab.platypus.flowables import Image, PageBreak, Spacer, XBox
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    59
    from reportlab.platypus.paragraph import Paragraph
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    60
    from reportlab.platypus.xpreformatted import XPreformatted
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    61
    from reportlab.platypus.flowables import Preformatted
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    62
    from reportlab.platypus.doctemplate import SimpleDocTemplate
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    63
    from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    64
    from reportlab.platypus.tables import GRID_STYLE, BOX_STYLE, LABELED_GRID_STYLE, COLORED_GRID_STYLE, LIST_STYLE, LongTable
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    65
    rowheights = (24, 16, 16, 16, 16)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    66
    rowheights2 = (24, 16, 16, 16, 30)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    67
    colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    68
    data = (
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    69
        ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    70
        ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    71
        ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    72
        ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    73
        ('Hats', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843')
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    74
        )
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    75
    data2 = (
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    76
        ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    77
        ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    78
        ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    79
        ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    80
        ('Hats\nLarge', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843')
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    81
        )
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    82
    styleSheet = getSampleStyleSheet()
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    83
    lst = []
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    84
    lst.append(Paragraph("Tables", styleSheet['Heading1']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    85
    lst.append(Paragraph(__doc__, styleSheet['BodyText']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    86
    lst.append(Paragraph("The Tables (shown in different styles below) were created using the following code:", styleSheet['BodyText']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    87
    lst.append(Preformatted("""
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    88
    colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    89
    rowheights = (24, 16, 16, 16, 16)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    90
    data = (
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    91
        ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun',
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    92
           'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    93
        ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    94
        ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    95
        ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    96
        ('Hats', 893, 912, '1,212', 643, 789, 159,
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    97
             888, '1,298', 832, 453, '1,344','2,843')
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    98
        )
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
    99
    t = Table(data, colwidths, rowheights)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   100
    """, styleSheet['Code'], dedent=4))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   101
    lst.append(Paragraph("""
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   102
    You can then give the Table a TableStyle object to control its format. The first TableStyle used was
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   103
    created as follows:
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   104
    """, styleSheet['BodyText']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   105
    lst.append(Preformatted("""
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   106
GRID_STYLE = TableStyle(
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   107
    [('GRID', (0,0), (-1,-1), 0.25, colors.black),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   108
     ('ALIGN', (1,1), (-1,-1), 'RIGHT')]
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   109
    )
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   110
    """, styleSheet['Code']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   111
    lst.append(Paragraph("""
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   112
    TableStyles are created by passing in a list of commands. There are two types of commands - line commands
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   113
    and cell formatting commands. In all cases, the first three elements of a command are the command name,
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   114
    the starting cell and the ending cell.
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   115
    """, styleSheet['BodyText']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   116
    lst.append(Paragraph("""
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   117
    Line commands always follow this with the weight and color of the desired lines. Colors can be names,
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   118
    or they can be specified as a (R,G,B) tuple, where R, G and B are floats and (0,0,0) is black. The line
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   119
    command names are: GRID, BOX, OUTLINE, INNERGRID, LINEBELOW, LINEABOVE, LINEBEFORE
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   120
    and LINEAFTER. BOX and OUTLINE are equivalent, and GRID is the equivalent of applying both BOX and
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   121
    INNERGRID.
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   122
    """, styleSheet['BodyText']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   123
    lst.append(Paragraph("""
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   124
    Cell formatting commands are:
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   125
    """, styleSheet['BodyText']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   126
    lst.append(Paragraph("""
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   127
    FONT - takes fontname, fontsize and (optional) leading.
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   128
    """, styleSheet['Definition']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   129
    lst.append(Paragraph("""
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   130
    TEXTCOLOR - takes a color name or (R,G,B) tuple.
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   131
    """, styleSheet['Definition']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   132
    lst.append(Paragraph("""
2461
9c24d39d05e8 enhanced decimal alignment
andy
parents: 2443
diff changeset
   133
    ALIGNMENT (or ALIGN) - takes one of LEFT, RIGHT, CENTRE (or CENTER) or DECIMAL.
2384
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   134
    """, styleSheet['Definition']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   135
    lst.append(Paragraph("""
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   136
    LEFTPADDING - defaults to 6.
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   137
    """, styleSheet['Definition']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   138
    lst.append(Paragraph("""
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   139
    RIGHTPADDING - defaults to 6.
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   140
    """, styleSheet['Definition']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   141
    lst.append(Paragraph("""
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   142
    BOTTOMPADDING - defaults to 3.
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   143
    """, styleSheet['Definition']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   144
    lst.append(Paragraph("""
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   145
    A tablestyle is applied to a table by calling Table.setStyle(tablestyle).
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   146
    """, styleSheet['BodyText']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   147
    t = Table(data, colwidths, rowheights)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   148
    t.setStyle(GRID_STYLE)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   149
    lst.append(PageBreak())
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   150
    lst.append(Paragraph("This is GRID_STYLE\n", styleSheet['BodyText']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   151
    lst.append(t)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   152
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   153
    t = Table(data, colwidths, rowheights)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   154
    t.setStyle(BOX_STYLE)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   155
    lst.append(Paragraph("This is BOX_STYLE\n", styleSheet['BodyText']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   156
    lst.append(t)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   157
    lst.append(Paragraph("""
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   158
    It was created as follows:
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   159
    """, styleSheet['BodyText']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   160
    lst.append(Preformatted("""
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   161
BOX_STYLE = TableStyle(
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   162
    [('BOX', (0,0), (-1,-1), 0.50, colors.black),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   163
     ('ALIGN', (1,1), (-1,-1), 'RIGHT')]
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   164
    )
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   165
    """, styleSheet['Code']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   166
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   167
    t = Table(data, colwidths, rowheights)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   168
    t.setStyle(LABELED_GRID_STYLE)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   169
    lst.append(Paragraph("This is LABELED_GRID_STYLE\n", styleSheet['BodyText']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   170
    lst.append(t)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   171
    t = Table(data2, colwidths, rowheights2)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   172
    t.setStyle(LABELED_GRID_STYLE)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   173
    lst.append(Paragraph("This is LABELED_GRID_STYLE ILLUSTRATES EXPLICIT LINE SPLITTING WITH NEWLINE (different heights and data)\n", styleSheet['BodyText']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   174
    lst.append(t)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   175
    lst.append(Paragraph("""
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   176
    It was created as follows:
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   177
    """, styleSheet['BodyText']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   178
    lst.append(Preformatted("""
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   179
LABELED_GRID_STYLE = TableStyle(
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   180
    [('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   181
     ('BOX', (0,0), (-1,-1), 2, colors.black),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   182
     ('LINEBELOW', (0,0), (-1,0), 2, colors.black),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   183
     ('LINEAFTER', (0,0), (0,-1), 2, colors.black),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   184
     ('ALIGN', (1,1), (-1,-1), 'RIGHT')]
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   185
    )
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   186
    """, styleSheet['Code']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   187
    lst.append(PageBreak())
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   188
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   189
    t = Table(data, colwidths, rowheights)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   190
    t.setStyle(COLORED_GRID_STYLE)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   191
    lst.append(Paragraph("This is COLORED_GRID_STYLE\n", styleSheet['BodyText']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   192
    lst.append(t)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   193
    lst.append(Paragraph("""
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   194
    It was created as follows:
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   195
    """, styleSheet['BodyText']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   196
    lst.append(Preformatted("""
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   197
COLORED_GRID_STYLE = TableStyle(
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   198
    [('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   199
     ('BOX', (0,0), (-1,-1), 2, colors.red),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   200
     ('LINEBELOW', (0,0), (-1,0), 2, colors.black),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   201
     ('LINEAFTER', (0,0), (0,-1), 2, colors.black),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   202
     ('ALIGN', (1,1), (-1,-1), 'RIGHT')]
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   203
    )
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   204
    """, styleSheet['Code']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   205
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   206
    t = Table(data, colwidths, rowheights)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   207
    t.setStyle(LIST_STYLE)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   208
    lst.append(Paragraph("This is LIST_STYLE\n", styleSheet['BodyText']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   209
    lst.append(t)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   210
    lst.append(Paragraph("""
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   211
    It was created as follows:
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   212
    """, styleSheet['BodyText']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   213
    lst.append(Preformatted("""
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   214
LIST_STYLE = TableStyle(
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   215
    [('LINEABOVE', (0,0), (-1,0), 2, colors.green),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   216
     ('LINEABOVE', (0,1), (-1,-1), 0.25, colors.black),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   217
     ('LINEBELOW', (0,-1), (-1,-1), 2, colors.green),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   218
     ('ALIGN', (1,1), (-1,-1), 'RIGHT')]
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   219
    )
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   220
    """, styleSheet['Code']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   221
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   222
    t = Table(data, colwidths, rowheights)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   223
    ts = TableStyle(
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   224
    [('LINEABOVE', (0,0), (-1,0), 2, colors.green),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   225
     ('LINEABOVE', (0,1), (-1,-1), 0.25, colors.black),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   226
     ('LINEBELOW', (0,-1), (-1,-1), 3, colors.green,'butt'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   227
     ('LINEBELOW', (0,-1), (-1,-1), 1, colors.white,'butt'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   228
     ('ALIGN', (1,1), (-1,-1), 'RIGHT'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   229
     ('TEXTCOLOR', (0,1), (0,-1), colors.red),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   230
     ('BACKGROUND', (0,0), (-1,0), colors.Color(0,0.7,0.7))]
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   231
    )
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   232
    t.setStyle(ts)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   233
    lst.append(Paragraph("This is a custom style\n", styleSheet['BodyText']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   234
    lst.append(t)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   235
    lst.append(Paragraph("""
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   236
    It was created as follows:
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   237
    """, styleSheet['BodyText']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   238
    lst.append(Preformatted("""
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   239
   ts = TableStyle(
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   240
    [('LINEABOVE', (0,0), (-1,0), 2, colors.green),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   241
     ('LINEABOVE', (0,1), (-1,-1), 0.25, colors.black),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   242
     ('LINEBELOW', (0,-1), (-1,-1), 3, colors.green,'butt'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   243
     ('LINEBELOW', (0,-1), (-1,-1), 1, colors.white,'butt'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   244
     ('ALIGN', (1,1), (-1,-1), 'RIGHT'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   245
     ('TEXTCOLOR', (0,1), (0,-1), colors.red),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   246
     ('BACKGROUND', (0,0), (-1,0), colors.Color(0,0.7,0.7))]
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   247
    )
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   248
    """, styleSheet['Code']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   249
    data = (
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   250
        ('', 'Jan\nCold', 'Feb\n', 'Mar\n','Apr\n','May\n', 'Jun\nHot', 'Jul\n', 'Aug\nThunder', 'Sep\n', 'Oct\n', 'Nov\n', 'Dec\n'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   251
        ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   252
        ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   253
        ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   254
        ('Hats', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843')
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   255
        )
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   256
    c = list(colwidths)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   257
    c[0] = None
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   258
    c[8] = None
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   259
    t = Table(data, c, [None]+list(rowheights[1:]))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   260
    t.setStyle(LIST_STYLE)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   261
    lst.append(Paragraph("""
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   262
        This is a LIST_STYLE table with the first rowheight set to None ie automatic.
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   263
        The top row cells are split at a newline '\\n' character. The first and August
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   264
        column widths were also set to None.
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   265
    """, styleSheet['BodyText']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   266
    lst.append(t)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   267
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   268
    lst.append(Paragraph("""
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   269
        This demonstrates a number of features useful in financial statements. The first is decimal alignment;
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   270
        with ALIGN=DECIMAL the numbers align on the points; and the points are aligned based on
2461
9c24d39d05e8 enhanced decimal alignment
andy
parents: 2443
diff changeset
   271
        the RIGHTPADDING, which is usually 3 points so you should set it higher.  The second is multiple lines;
2384
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   272
        one can specify double or triple lines and control the separation if desired. Finally, the coloured
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   273
        negative numbers were (we regret to say) done in the style; we don't have a way to conditionally
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   274
        format numbers based on value yet.
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   275
    """, styleSheet['BodyText']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   276
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   277
2589
1af821ded9f1 added japanese splitting test, and table preprocessor to convert unicode->utf8
andy
parents: 2575
diff changeset
   278
    t = Table([[u'Corporate Assets','Amount'],
2384
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   279
               ['Fixed Assets','1,234,567.89'],
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   280
               ['Company Vehicle','1,234.8901'],
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   281
               ['Petty Cash','42'],
2589
1af821ded9f1 added japanese splitting test, and table preprocessor to convert unicode->utf8
andy
parents: 2575
diff changeset
   282
               [u'Intellectual Property\u00ae','(42,078,231.56)'],
2461
9c24d39d05e8 enhanced decimal alignment
andy
parents: 2443
diff changeset
   283
               ['Overdraft','(12,345)'],
9c24d39d05e8 enhanced decimal alignment
andy
parents: 2443
diff changeset
   284
               ['Boardroom Flat Screen','60 inches'],
2384
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   285
               ['Net Position','Deep Sh*t.Really']
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   286
               ],
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   287
              [144,72])
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   288
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   289
    ts = TableStyle(
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   290
        [#first the top row
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   291
         ('ALIGN', (1,1), (-1,-1), 'CENTER'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   292
         ('LINEABOVE', (0,0), (-1,0), 1, colors.purple),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   293
         ('LINEBELOW', (0,0), (-1,0), 1, colors.purple),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   294
         ('FONT', (0,0), (-1,0), 'Times-Bold'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   295
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   296
        #bottom row has a line above, and two lines below
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   297
         ('LINEABOVE', (0,-1), (-1,-1), 1, colors.purple),  #last 2 are count, sep
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   298
         ('LINEBELOW', (0,-1), (-1,-1), 0.5, colors.purple, 1, None, None, 4,1),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   299
         ('LINEBELOW', (0,-1), (-1,-1), 1, colors.red),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   300
         ('FONT', (0,-1), (-1,-1), 'Times-Bold'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   301
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   302
        #numbers column
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   303
         ('ALIGN', (1,1), (-1,-1), 'DECIMAL'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   304
         ('RIGHTPADDING', (1,1), (-1,-1), 36),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   305
         ('TEXTCOLOR', (1,4), (1,4), colors.red),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   306
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   307
        #red cell         
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   308
        ]
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   309
        )
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   310
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   311
    t.setStyle(ts)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   312
    lst.append(t)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   313
    lst.append(Spacer(36,36))    
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   314
    lst.append(Paragraph("""
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   315
        The red numbers should be aligned LEFT & BOTTOM, the blue RIGHT & TOP
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   316
        and the green CENTER & MIDDLE.
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   317
    """, styleSheet['BodyText']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   318
    XY  =   [['X00y', 'X01y', 'X02y', 'X03y', 'X04y'],
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   319
            ['X10y', 'X11y', 'X12y', 'X13y', 'X14y'],
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   320
            ['X20y', 'X21y', 'X22y', 'X23y', 'X24y'],
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   321
            ['X30y', 'X31y', 'X32y', 'X33y', 'X34y']]
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   322
    t=Table(XY, 5*[0.6*inch], 4*[0.6*inch])
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   323
    t.setStyle([('ALIGN',(1,1),(-2,-2),'LEFT'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   324
                ('TEXTCOLOR',(1,1),(-2,-2),colors.red),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   325
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   326
                ('VALIGN',(0,0),(1,-1),'TOP'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   327
                ('ALIGN',(0,0),(1,-1),'RIGHT'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   328
                ('TEXTCOLOR',(0,0),(1,-1),colors.blue),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   329
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   330
                ('ALIGN',(0,-1),(-1,-1),'CENTER'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   331
                ('VALIGN',(0,-1),(-1,-1),'MIDDLE'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   332
                ('TEXTCOLOR',(0,-1),(-1,-1),colors.green),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   333
                ('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   334
                ('BOX', (0,0), (-1,-1), 0.25, colors.black),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   335
                ])
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   336
    lst.append(t)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   337
    data = [('alignment', 'align\012alignment'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   338
            ('bulletColor', 'bulletcolor\012bcolor'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   339
            ('bulletFontName', 'bfont\012bulletfontname'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   340
            ('bulletFontSize', 'bfontsize\012bulletfontsize'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   341
            ('bulletIndent', 'bindent\012bulletindent'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   342
            ('firstLineIndent', 'findent\012firstlineindent'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   343
            ('fontName', 'face\012fontname\012font'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   344
            ('fontSize', 'size\012fontsize'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   345
            ('leading', 'leading'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   346
            ('leftIndent', 'leftindent\012lindent'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   347
            ('rightIndent', 'rightindent\012rindent'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   348
            ('spaceAfter', 'spaceafter\012spacea'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   349
            ('spaceBefore', 'spacebefore\012spaceb'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   350
            ('textColor', 'fg\012textcolor\012color')]
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   351
    t = Table(data)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   352
    t.setStyle([
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   353
            ('VALIGN',(0,0),(-1,-1),'TOP'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   354
            ('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   355
            ('BOX', (0,0), (-1,-1), 0.25, colors.black),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   356
            ])
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   357
    lst.append(t)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   358
    t = Table([ ('Attribute', 'Synonyms'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   359
                ('alignment', 'align, alignment'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   360
                ('bulletColor', 'bulletcolor, bcolor'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   361
                ('bulletFontName', 'bfont, bulletfontname'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   362
                ('bulletFontSize', 'bfontsize, bulletfontsize'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   363
                ('bulletIndent', 'bindent, bulletindent'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   364
                ('firstLineIndent', 'findent, firstlineindent'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   365
                ('fontName', 'face, fontname, font'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   366
                ('fontSize', 'size, fontsize'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   367
                ('leading', 'leading'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   368
                ('leftIndent', 'leftindent, lindent'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   369
                ('rightIndent', 'rightindent, rindent'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   370
                ('spaceAfter', 'spaceafter, spacea'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   371
                ('spaceBefore', 'spacebefore, spaceb'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   372
                ('textColor', 'fg, textcolor, color')])
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   373
    t.repeatRows = 1
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   374
    t.setStyle([
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   375
                ('FONT',(0,0),(-1,1),'Times-Bold',10,12),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   376
                ('FONT',(0,1),(-1,-1),'Courier',8,8),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   377
                ('VALIGN',(0,0),(-1,-1),'MIDDLE'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   378
                ('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   379
                ('BOX', (0,0), (-1,-1), 0.25, colors.black),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   380
                ('BACKGROUND', (0, 0), (-1, 0), colors.green),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   381
                ('BACKGROUND', (0, 1), (-1, -1), colors.pink),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   382
                ('ALIGN', (0, 0), (-1, 0), 'CENTER'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   383
                ('ALIGN', (0, 1), (0, -1), 'LEFT'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   384
                ('ALIGN', (-1, 1), (-1, -1), 'RIGHT'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   385
                ('FONT', (0, 0), (-1, 0), 'Times-Bold', 12),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   386
                ('ALIGN', (1, 1), (1, -1), 'CENTER'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   387
                ])
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   388
    lst.append(t)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   389
    lst.append(Table(XY,
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   390
            style=[ ('FONT',(0,0),(-1,-1),'Times-Roman', 5,6),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   391
                    ('GRID', (0,0), (-1,-1), 0.25, colors.blue),]))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   392
    lst.append(Table(XY,
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   393
            style=[ ('FONT',(0,0),(-1,-1),'Times-Roman', 10,12),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   394
                    ('GRID', (0,0), (-1,-1), 0.25, colors.black),]))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   395
    lst.append(Table(XY,
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   396
            style=[ ('FONT',(0,0),(-1,-1),'Times-Roman', 20,24),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   397
                    ('GRID', (0,0), (-1,-1), 0.25, colors.red),]))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   398
    lst.append(PageBreak())
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   399
    data=  [['00', '01', '02', '03', '04'],
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   400
            ['10', '11', '12', '13', '14'],
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   401
            ['20', '21', '22', '23', '24'],
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   402
            ['30', '31', '32', '33', '34']]
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   403
    t=Table(data,style=[
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   404
                    ('GRID',(0,0),(-1,-1),0.5,colors.grey),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   405
                    ('GRID',(1,1),(-2,-2),1,colors.green),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   406
                    ('BOX',(0,0),(1,-1),2,colors.red),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   407
                    ('BOX',(0,0),(-1,-1),2,colors.black),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   408
                    ('LINEABOVE',(1,2),(-2,2),1,colors.blue),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   409
                    ('LINEBEFORE',(2,1),(2,-2),1,colors.pink),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   410
                    ('BACKGROUND', (0, 0), (0, 1), colors.pink),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   411
                    ('BACKGROUND', (1, 1), (1, 2), colors.lavender),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   412
                    ('BACKGROUND', (2, 2), (2, 3), colors.orange),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   413
                    ])
2443
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   414
    lst.append(Paragraph("Illustrating splits: nosplit", styleSheet['BodyText']))
2384
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   415
    lst.append(t)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   416
    lst.append(Spacer(0,6))
2443
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   417
    lst.append(Paragraph("Illustrating splits: split(4in,30)", styleSheet['BodyText']))
2384
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   418
    for s in t.split(4*inch,30):
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   419
        lst.append(s)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   420
        lst.append(Spacer(0,6))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   421
    lst.append(Spacer(0,6))
2443
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   422
    lst.append(Paragraph("Illustrating splits: split(4in,36)", styleSheet['BodyText']))
2384
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   423
    for s in t.split(4*inch,36):
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   424
        lst.append(s)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   425
        lst.append(Spacer(0,6))
2443
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   426
    lst.append(Paragraph("Illustrating splits: split(4in,56)", styleSheet['BodyText']))
2384
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   427
    lst.append(Spacer(0,6))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   428
    for s in t.split(4*inch,56):
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   429
        lst.append(s)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   430
        lst.append(Spacer(0,6))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   431
2443
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   432
    lst.append(PageBreak())
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   433
    data=  [['00', '01', '02', '03', '04'],
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   434
            ['', '11', '12', '13', '14'],
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   435
            ['20', '21', '22', '23', '24'],
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   436
            ['30', '31', '', '33', '34']]
2475
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   437
    sty=[
2443
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   438
                    ('GRID',(0,0),(-1,-1),0.5,colors.grey),
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   439
                    ('GRID',(1,1),(-2,-2),1,colors.green),
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   440
                    ('BOX',(0,0),(1,-1),2,colors.red),
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   441
                    ('BOX',(0,0),(-1,-1),2,colors.black),
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   442
                    ('LINEABOVE',(1,2),(-2,2),1,colors.blue),
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   443
                    ('LINEBEFORE',(2,1),(2,-2),1,colors.pink),
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   444
                    ('BACKGROUND', (0, 0), (0, 1), colors.pink),
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   445
                    ('SPAN',(0,0),(0,1)),
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   446
                    ('BACKGROUND', (2, 2), (2, 3), colors.orange),
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   447
                    ('SPAN',(2,2),(2,3)),
2475
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   448
                    ]
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   449
    t=Table(data,style=sty)
2443
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   450
    lst.append(Paragraph("Illustrating splits with spans: nosplit", styleSheet['BodyText']))
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   451
    lst.append(t)
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   452
    lst.append(Spacer(0,6))
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   453
    lst.append(Paragraph("Illustrating splits with spans: split(4in,30)", styleSheet['BodyText']))
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   454
    for s in t.split(4*inch,30):
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   455
        lst.append(s)
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   456
        lst.append(Spacer(0,6))
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   457
    lst.append(Spacer(0,6))
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   458
    lst.append(Paragraph("Illustrating splits with spans: split(4in,36)", styleSheet['BodyText']))
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   459
    for s in t.split(4*inch,36):
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   460
        lst.append(s)
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   461
        lst.append(Spacer(0,6))
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   462
    lst.append(Paragraph("Illustrating splits with spans: split(4in,56)", styleSheet['BodyText']))
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   463
    lst.append(Spacer(0,6))
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   464
    for s in t.split(4*inch,56):
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   465
        lst.append(s)
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   466
        lst.append(Spacer(0,6))
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   467
2475
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   468
    data=  [['00', '01', '02', '03', '04'],
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   469
            ['', '11', '12', '13', ''],
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   470
            ['20', '21', '22', '23', '24'],
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   471
            ['30', '31', '', '33', ''],
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   472
            ['40', '41', '', '43', '44']]
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   473
    sty=[
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   474
        ('GRID',(0,0),(-1,-1),0.5,colors.grey),
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   475
        ('GRID',(1,1),(-2,-2),1,colors.green),
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   476
        ('BOX',(0,0),(1,-1),2,colors.red),
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   477
        ('BOX',(0,0),(-1,-1),2,colors.black),
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   478
        ('LINEABOVE',(1,2),(-2,2),1,colors.blue),
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   479
        ('LINEBEFORE',(2,1),(2,-2),1,colors.pink),
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   480
        ('BACKGROUND', (0, 0), (0, 1), colors.pink),
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   481
        ('SPAN',(0,0),(0,1)),
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   482
        ('BACKGROUND',(-2,1),(-1,1),colors.palegreen),
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   483
        ('SPAN',(-2,1),(-1,1)),
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   484
        ('BACKGROUND',(-2,3),(-1,3),colors.yellow),
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   485
        ('SPAN',(-2,3),(-1,3)),
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   486
        ('BACKGROUND', (2, 3), (2, 4), colors.orange),
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   487
        ('SPAN',(2,3),(2,4)),
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   488
        ]
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   489
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   490
    t=Table(data,style=sty,repeatRows=2)
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   491
    lst.append(Paragraph("Illustrating splits with spans and repeatRows: nosplit", styleSheet['BodyText']))
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   492
    lst.append(t)
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   493
    lst.append(Spacer(0,6))
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   494
    if  0:
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   495
        lst.append(Paragraph("Illustrating splits with spans and repeatRows: split(4in,30)", styleSheet['BodyText']))
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   496
        for s in t.split(4*inch,30):
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   497
            lst.append(s)
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   498
            lst.append(Spacer(0,6))
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   499
        lst.append(Spacer(0,6))
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   500
        lst.append(Paragraph("Illustrating splits with spans and repeatRows: split(4in,36)", styleSheet['BodyText']))
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   501
        for s in t.split(4*inch,36):
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   502
            lst.append(s)
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   503
            lst.append(Spacer(0,6))
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   504
    lst.append(Paragraph("Illustrating splits with spans and repeatRows: split(4in,56)", styleSheet['BodyText']))
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   505
    lst.append(Spacer(0,6))
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   506
    t=Table(data,style=sty,repeatRows=2)
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   507
    for s in t.split(4*inch,56):
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   508
        lst.append(s)
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   509
        lst.append(Spacer(0,6))
24a8e6ffc36a tables.py: fixes to split + spans
rgbecker
parents: 2461
diff changeset
   510
2443
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   511
    lst.append(PageBreak())
2384
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   512
    import os, reportlab.platypus
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   513
    I = Image(os.path.join(os.path.dirname(reportlab.platypus.__file__),'..','tools','pythonpoint','demos','leftlogo.gif'))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   514
    I.drawHeight = 1.25*inch*I.drawHeight / I.drawWidth
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   515
    I.drawWidth = 1.25*inch
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   516
    #I.drawWidth = 9.25*inch #uncomment to see better messaging
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   517
    P = Paragraph("<para align=center spaceb=3>The <b>ReportLab Left <font color=red>Logo</font></b> Image</para>", styleSheet["BodyText"])
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   518
    data=  [['A', 'B', 'C', Paragraph("<b>A pa<font color=red>r</font>a<i>graph</i></b><super><font color=yellow>1</font></super>",styleSheet["BodyText"]), 'D'],
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   519
            ['00', '01', '02', [I,P], '04'],
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   520
            ['10', '11', '12', [I,P], '14'],
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   521
            ['20', '21', '22', '23', '24'],
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   522
            ['30', '31', '32', '33', '34']]
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   523
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   524
    t=Table(data,style=[('GRID',(1,1),(-2,-2),1,colors.green),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   525
                    ('BOX',(0,0),(1,-1),2,colors.red),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   526
                    ('LINEABOVE',(1,2),(-2,2),1,colors.blue),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   527
                    ('LINEBEFORE',(2,1),(2,-2),1,colors.pink),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   528
                    ('BACKGROUND', (0, 0), (0, 1), colors.pink),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   529
                    ('BACKGROUND', (1, 1), (1, 2), colors.lavender),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   530
                    ('BACKGROUND', (2, 2), (2, 3), colors.orange),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   531
                    ('BOX',(0,0),(-1,-1),2,colors.black),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   532
                    ('GRID',(0,0),(-1,-1),0.5,colors.black),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   533
                    ('VALIGN',(3,0),(3,0),'BOTTOM'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   534
                    ('BACKGROUND',(3,0),(3,0),colors.limegreen),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   535
                    ('BACKGROUND',(3,1),(3,1),colors.khaki),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   536
                    ('ALIGN',(3,1),(3,1),'CENTER'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   537
                    ('BACKGROUND',(3,2),(3,2),colors.beige),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   538
                    ('ALIGN',(3,2),(3,2),'LEFT'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   539
                    ])
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   540
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   541
    t._argW[3]=1.5*inch
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   542
    lst.append(t)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   543
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   544
    # now for an attempt at column spanning.
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   545
    lst.append(PageBreak())
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   546
    data=  [['A', 'BBBBB', 'C', 'D', 'E'],
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   547
            ['00', '01', '02', '03', '04'],
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   548
            ['10', '11', '12', '13', '14'],
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   549
            ['20', '21', '22', '23', '24'],
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   550
            ['30', '31', '32', '33', '34']]
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   551
    sty = [
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   552
            ('ALIGN',(0,0),(-1,-1),'CENTER'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   553
            ('VALIGN',(0,0),(-1,-1),'TOP'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   554
            ('GRID',(0,0),(-1,-1),1,colors.green),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   555
            ('BOX',(0,0),(-1,-1),2,colors.red),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   556
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   557
            #span 'BBBB' across middle 3 cells in top row
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   558
            ('SPAN',(1,0),(3,0)),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   559
            #now color the first cell in this range only,
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   560
            #i.e. the one we want to have spanned.  Hopefuly
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   561
            #the range of 3 will come out khaki.
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   562
            ('BACKGROUND',(1,0),(1,0),colors.khaki),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   563
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   564
            ('SPAN',(0,2),(-1,2)),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   565
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   566
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   567
            #span 'AAA'down entire left column
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   568
            ('SPAN',(0,0), (0, 1)),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   569
            ('BACKGROUND',(0,0),(0,0),colors.cyan),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   570
            ('LINEBELOW', (0,'splitlast'), (-1,'splitlast'), 1, colors.white,'butt'),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   571
           ]
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   572
    t=Table(data,style=sty, colWidths = [20] * 5, rowHeights = [20]*5)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   573
    lst.append(t)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   574
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   575
    # now for an attempt at percentage widths
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   576
    lst.append(Spacer(18,18))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   577
    lst.append(Paragraph("This table has colWidths=5*['14%']!", styleSheet['BodyText']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   578
    t=Table(data,style=sty, colWidths = ['14%'] * 5, rowHeights = [20]*5)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   579
    lst.append(t)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   580
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   581
    lst.append(Spacer(18,18))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   582
    lst.append(Paragraph("This table has colWidths=['14%','10%','19%','22%','*']!", styleSheet['BodyText']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   583
    t=Table(data,style=sty, colWidths = ['14%','10%','19%','22%','*'], rowHeights = [20]*5)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   584
    lst.append(t)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   585
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   586
    # Mike's test example
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   587
    lst.append(Spacer(18,18))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   588
    lst.append(Paragraph('Mike\'s Spanning Example', styleSheet['Heading1']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   589
    data=  [[Paragraph('World Domination: The First Five Years', styleSheet['BodyText']), ''],
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   590
            [Paragraph('World <font color="green">Domination</font>: The First Five Years', styleSheet['BodyText']),''],
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   591
            [Paragraph('World Domination: The First Five Years', styleSheet['BodyText']), ''],
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   592
            ]
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   593
    t=Table(data, style=[('SPAN',(0,0),(1,0)),('SPAN',(0,1),(1,1)),('SPAN',(0,2),(1,2)),], colWidths = [3*cm,8*cm], rowHeights = [None]*3)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   594
    lst.append(t)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   595
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   596
    lst.append(Spacer(18,18))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   597
    lst.append(Paragraph('Mike\'s Non-spanning Example', styleSheet['Heading1']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   598
    data=  [[Paragraph('World Domination: The First Five Years', styleSheet['BodyText'])],
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   599
            [Paragraph('World <font color="magenta">Domination</font>: The First Five Years', styleSheet['BodyText'])],
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   600
            [Paragraph('World Domination: The First Five Years', styleSheet['BodyText'])],
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   601
            ]
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   602
    t=Table(data, style=[], colWidths = [11*cm], rowHeights = [None]*3)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   603
    lst.append(t)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   604
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   605
    lst.append(Spacer(18,18))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   606
    lst.append(Paragraph('xpre example', styleSheet['Heading1']))
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   607
    data=  [    [
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   608
                XPreformatted('Account Details', styleSheet['Heading3']),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   609
                '', XPreformatted('Client Details', styleSheet['Heading3']),
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   610
                ],  #end of row 0
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   611
            ]
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   612
    t=Table(data, style=[], colWidths = [80,230.0,80], rowHeights = [None]*1)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   613
    lst.append(t)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   614
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   615
    lst.append(PageBreak())
2392
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   616
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   617
    lst.append(Paragraph('Trying colour cycling in background', styleSheet['Heading1']))
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   618
    lst.append(Paragraph("This should alternate pale blue and uncolored by row", styleSheet['BodyText']))
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   619
    data=  [['001', '01', '02', '03', '04', '05'],
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   620
            ['002', '01', '02', '03', '04', '05'],
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   621
            ['003', '01', '02', '03', '04', '05'],
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   622
            ['004', '01', '02', '03', '04', '05'],
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   623
            ['005', '01', '02', '03', '04', '05'],
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   624
            ['006', '01', '02', '03', '04', '05'],
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   625
            ['007', '01', '02', '03', '04', '05'],
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   626
            ['008', '01', '02', '03', '04', '05'],
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   627
            ['009', '01', '02', '03', '04', '05'],
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   628
            ['010', '01', '02', '03', '04', '05'],
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   629
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   630
            ]
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   631
    t=Table(data,style=[
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   632
                    ('GRID',(0,0),(-1,-1),0.5,colors.grey),
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   633
                    ('ROWBACKGROUNDS', (0, 0), (-1, -1), (0xD0D0FF, None)),
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   634
                    ])
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   635
    lst.append(t)
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   636
    lst.append(Spacer(0,6))
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   637
    lst.append(Paragraph("And this should pale blue, pale pink and None by column", styleSheet['BodyText']))
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   638
    data=  [['001', '01', '02', '03', '04', '05'],
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   639
            ['002', '01', '02', '03', '04', '05'],
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   640
            ['003', '01', '02', '03', '04', '05'],
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   641
            ['004', '01', '02', '03', '04', '05'],
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   642
            ['005', '01', '02', '03', '04', '05'],
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   643
            ['006', '01', '02', '03', '04', '05'],
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   644
            ['007', '01', '02', '03', '04', '05'],
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   645
            ['008', '01', '02', '03', '04', '05'],
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   646
            ['009', '01', '02', '03', '04', '05'],
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   647
            ['010', '01', '02', '03', '04', '05'],
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   648
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   649
            ]
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   650
    t=Table(data,style=[
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   651
                    ('GRID',(0,0),(-1,-1),0.5,colors.grey),
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   652
                    ('COLBACKGROUNDS', (0, 0), (-1, -1), (0xD0D0FF, 0xFFD0D0, None)),
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   653
                    ])
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   654
    lst.append(t)
6c59b0eb312d table color cycle changes
andy
parents: 2384
diff changeset
   655
2412
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   656
    lst.append(PageBreak())
2443
41262322cc3d tables.py: added span rows split handling & test contributed by Andre Reitz
rgbecker
parents: 2414
diff changeset
   657
    lst.append(Paragraph("This spanning example illustrates automatic removal of grids and lines in spanned cells!", styleSheet['BodyText']))
2414
81be267fa92c tables.py: extend span line blocking to multi lines
rgbecker
parents: 2412
diff changeset
   658
    lst.append(Spacer(0,6))
2412
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   659
    data=  [['Top\nLeft', '', '02', '03', '04', '05', '06', '07'],
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   660
            ['', '', '12', 'Span (3,1) (6,2)', '','','','17'],
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   661
            ['20', '21', '22', '', '','','','27'],
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   662
            ['30', '31', '32', '33', '34','35','36','37'],
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   663
            ['40', 'In The\nMiddle', '', '', '44','45','46','47'],
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   664
            ['50', '', '', '', '54','55','56','57'],
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   665
            ['60', '', '', '','64', '65', 'Bottom\nRight', ''],
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   666
            ['70', '71', '72', '73','74', '75', '', '']]
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   667
    t=Table(data,style=[
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   668
            ('GRID',(0,0),(-1,-1),0.5,colors.grey),
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   669
            ('BACKGROUND',(0,0),(1,1),colors.palegreen),
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   670
            ('SPAN',(0,0),(1,1)),
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   671
            ('BACKGROUND',(-2,-2),(-1,-1), colors.pink),
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   672
            ('SPAN',(-2,-2),(-1,-1)),
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   673
            ('SPAN',(1,4),(3,6)),
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   674
            ('BACKGROUND',(1,4),(3,6), colors.lightblue),
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   675
            ('SPAN',(3,1),(6,2)),
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   676
            ('BACKGROUND',(3,1),(6,2), colors.peachpuff),
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   677
            ('VALIGN',(3,1),(6,2),'TOP'),
2414
81be267fa92c tables.py: extend span line blocking to multi lines
rgbecker
parents: 2412
diff changeset
   678
            ('LINEABOVE', (0,2),(-1,2), 1, colors.black, 0, None, None, 2, 2),
81be267fa92c tables.py: extend span line blocking to multi lines
rgbecker
parents: 2412
diff changeset
   679
            ('LINEBEFORE', (3,0),(3,-1), 1, colors.black, 0, None, None, 2, 2),
2412
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   680
            ])
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   681
    lst.append(t)
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   682
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   683
    lst.append(PageBreak())
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   684
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   685
    lst.append(Paragraph("und jetzt noch eine Tabelle mit 5000 Zeilen:", styleSheet['BodyText']))
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   686
    sty = [ ('GRID',(0,0),(-1,-1),1,colors.green),
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   687
            ('BOX',(0,0),(-1,-1),2,colors.red),
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   688
           ]
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   689
    data = [[str(i), Paragraph("xx "* (i%10), styleSheet["BodyText"]), Paragraph("blah "*(i%40), styleSheet["BodyText"])] for i in xrange(500)]
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   690
    t=LongTable(data, style=sty, colWidths = [50,100,200])
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   691
    lst.append(t)
b8bf2e639769 reportlab: table improvments and better documentation
rgbecker
parents: 2392
diff changeset
   692
2819
0af8d3e7dfc9 tables.py: fix inspired by Yuan Hong's bug report
rgbecker
parents: 2589
diff changeset
   693
    #Yuan Hong's bug tester
0af8d3e7dfc9 tables.py: fix inspired by Yuan Hong's bug report
rgbecker
parents: 2589
diff changeset
   694
    lst.append(PageBreak())
0af8d3e7dfc9 tables.py: fix inspired by Yuan Hong's bug report
rgbecker
parents: 2589
diff changeset
   695
    lst.append(Paragraph('Yian Hong\'s Bug Case (should not blow up)', styleSheet['Heading2']))
0af8d3e7dfc9 tables.py: fix inspired by Yuan Hong's bug report
rgbecker
parents: 2589
diff changeset
   696
    data = ([['Col1', 'Col2', 'Col3', 'Col4', 'Col5']]+
0af8d3e7dfc9 tables.py: fix inspired by Yuan Hong's bug report
rgbecker
parents: 2589
diff changeset
   697
                [['01', Paragraph('This is cell one that contains a paragraph.', styleSheet['Normal']), '02', '03', '04']
0af8d3e7dfc9 tables.py: fix inspired by Yuan Hong's bug report
rgbecker
parents: 2589
diff changeset
   698
                    for i in xrange(50)])
0af8d3e7dfc9 tables.py: fix inspired by Yuan Hong's bug report
rgbecker
parents: 2589
diff changeset
   699
0af8d3e7dfc9 tables.py: fix inspired by Yuan Hong's bug report
rgbecker
parents: 2589
diff changeset
   700
    t = Table(data, ['20%']*5, repeatRows=1)
0af8d3e7dfc9 tables.py: fix inspired by Yuan Hong's bug report
rgbecker
parents: 2589
diff changeset
   701
    t.setStyle(TableStyle([
0af8d3e7dfc9 tables.py: fix inspired by Yuan Hong's bug report
rgbecker
parents: 2589
diff changeset
   702
        ('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
0af8d3e7dfc9 tables.py: fix inspired by Yuan Hong's bug report
rgbecker
parents: 2589
diff changeset
   703
        ('BOX', (0,0), (-1,-1), 0.25, colors.black),
0af8d3e7dfc9 tables.py: fix inspired by Yuan Hong's bug report
rgbecker
parents: 2589
diff changeset
   704
        ('SPAN', (0,50), (-2,50)),
0af8d3e7dfc9 tables.py: fix inspired by Yuan Hong's bug report
rgbecker
parents: 2589
diff changeset
   705
        ]))
0af8d3e7dfc9 tables.py: fix inspired by Yuan Hong's bug report
rgbecker
parents: 2589
diff changeset
   706
0af8d3e7dfc9 tables.py: fix inspired by Yuan Hong's bug report
rgbecker
parents: 2589
diff changeset
   707
    lst.append(t)
0af8d3e7dfc9 tables.py: fix inspired by Yuan Hong's bug report
rgbecker
parents: 2589
diff changeset
   708
2878
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   709
    #Volker Haas' example
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   710
    sty=[
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   711
        ('TOPPADDING',(0,0),(-1,-1),0),
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   712
        ('BOTTOMPADDING',(0,0),(-1,-1),0),
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   713
        ('RIGHTPADDING',(0,0),(-1,-1),0),
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   714
        ('LEFTPADDING',(0,0),(-1,-1),0),
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   715
        ('GRID',(0,0),(-1,-1),0.5,colors.grey),
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   716
        ('BACKGROUND', (0, 0), (0, 1), colors.pink),
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   717
        ('SPAN',(0,0),(0,1)),
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   718
        ('BACKGROUND', (2, 2), (2, 3), colors.orange),
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   719
        ('SPAN',(2,2),(2,3)),
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   720
        ('SPAN',(3,1),(4,1)),
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   721
        ]
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   722
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   723
    p_style= ParagraphStyle('Normal')
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   724
    data=  [['00', '01', '02', '03', '04'],
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   725
            ['', '11', '12', Paragraph('This is a string',p_style), ''],
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   726
            ['20', '21', Paragraph('22<br/>blub<br/>asfd<br/>afd<br/>asdfs', p_style), '23', '24'],
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   727
            ['30', '31', '', '33', '34']]
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   728
    lst.append(Table(data,style=sty))
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   729
    lst.append(Spacer(10,10))
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   730
    data1=  [['00', '01', '02', '03', '04'],
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   731
            ['', '11', '12', XPreformatted('This is a string',p_style), ''],
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   732
            ['20', '21', Paragraph('22<br/>blub<br/>asfd<br/>afd<br/>asdfs',p_style), '23', '24'],
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   733
            ['30', '31', '', '33', '34']]
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   734
    lst.append(Table(data1,style=sty))
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   735
    lst.append(Spacer(10,10))
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   736
    data2=  [['00', '01', '02', '03', '04'],
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   737
            ['', '11', '12', 'This is a string', ''],
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   738
            ['20', '21','22\nblub\nasfd\nafd\nasdfs', '23', '24'],
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   739
            ['30', '31', '', '33', '34']]
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   740
    lst.append(Table(data2,style=sty))
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   741
    data3=  [['00', '01', '02', '03', '04'],
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   742
            ['', '11', '12', 'This is a string', ''],
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   743
            ['20', '21', Paragraph('22<br/>blub<br/>asfd<br/>afd<br/>asdfs',p_style), '23', '24'],
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   744
            ['30', '31', '', '33', '34']]
a7af19b6f9fb reportlab: fix cell spanning bug in tables.py (from Volker Haas)
rgbecker
parents: 2819
diff changeset
   745
    lst.append(Table(data3,style=sty))
2384
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   746
    SimpleDocTemplate(outputfile('tables.pdf'), showBoundary=1).build(lst)
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   747
857
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
   748
class TablesTestCase(unittest.TestCase):
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
   749
    "Make documents with tables"
1667
dfe2f821f4e2 Slightly refactored test suite to do the same thing with less code.
dinu_gherman
parents: 857
diff changeset
   750
dfe2f821f4e2 Slightly refactored test suite to do the same thing with less code.
dinu_gherman
parents: 857
diff changeset
   751
    def test0(self):
857
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
   752
        "Make a document full of tables"
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
   753
        run()
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
   754
2384
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   755
    def test1(self):
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   756
        "Make a document full of tables"
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   757
        old_tables_test()
6d44252e1042 platypus: added ptocontainer, moved tables test
rgbecker
parents: 2332
diff changeset
   758
1667
dfe2f821f4e2 Slightly refactored test suite to do the same thing with less code.
dinu_gherman
parents: 857
diff changeset
   759
857
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
   760
def makeSuite():
1667
dfe2f821f4e2 Slightly refactored test suite to do the same thing with less code.
dinu_gherman
parents: 857
diff changeset
   761
    return makeSuiteForClasses(TablesTestCase)
857
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
   762
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
   763
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
   764
#noruntests
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
   765
if __name__ == "__main__":
0e2245922315 Added tests formerly under platypus/test
andy_robinson
parents:
diff changeset
   766
    unittest.TextTestRunner().run(makeSuite())
2505
0859d48c2558 reportlab/test: fix so individual tests print output folder location
rgbecker
parents: 2475
diff changeset
   767
    printLocation()