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