1
<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
2
<!DOCTYPE document SYSTEM "rml_1_0.dtd">
3
<document filename="test_008_tables.pdf">
4
<template pageSize="(595, 842)" leftMargin="72" showBoundary="1">
5
<pageTemplate id="main">
6
<frame id="first" x1="1in" y1="1in" width="6.27in" height="9.69in"/>
10
<blockTableStyle id="temp001">
11
<blockAlignment value="left"/>
12
<blockFont name="Helvetica-Oblique"/>
13
<lineStyle kind="GRID" colorName="black"/>
14
<lineStyle kind="OUTLINE" colorName="black" thickness="2"/>
15
<blockBackground colorName="pink" start="0,0" stop="-1,0"/>
16
<blockBackground colorName="yellow" start="0,0" stop="-1,0"/>
18
<blockTableStyle id="span001">
19
<blockAlignment value="center"/>
20
<blockValign value="middle" start="-1,0" stop="-1,-1"/>
21
<blockSpan start="0,0" stop="2,0"/>
22
<blockSpan start="-1,0" stop="-1,-1"/>
23
<lineStyle kind="GRID" colorName="black" start="0,1" stop="-2,-1"/>
24
<lineStyle kind="GRID" colorName="black" start="3,0" stop="3,0"/>
25
<lineStyle kind="OUTLINE" colorName="black" thickness="2"/>
27
<blockTableStyle id="numeric">
28
<!--top row - centre and bold, easy-->
29
<blockFont name="Times-Bold" start="0,0" stop="-1,0"/>
30
<blockAlignment value="center" start="0,0" stop="-1,0"/>
31
<lineStyle kind="LINEABOVE" colorName="purple" start="0,0" stop="-1,0"/>
32
<lineStyle kind="LINEBELOW" colorName="purple" start="0,0" stop="-1,0"/>
33
<!--numeric region - decimal align and set right padding-->
34
<blockAlignment value="right" start="1,1" stop="-1,-1"/>
35
<!--bottom row - double underline-->
36
<blockFont name="Times-Bold" start="0,-1" stop="-1,-1"/>
37
<lineStyle kind="LINEABOVE" colorName="purple" start="0,-1" stop="-1,-1"/>
38
<lineStyle kind="LINEBELOW" colorName="purple" start="0,-1" stop="-1,-1" count="2"/>
42
<para>The email address should be a clickable mailto link built by creating a plugin within the cell. And Robin's job title
43
should be on a separate line to his name. In the third row, we use the newer and easier table cell properties "href" and "destination".</para>
45
<blockTable colWidths="5cm,5cm" style="temp001">
52
(chief propellerhead)</td>
54
<plugInFlowable module="mymodule" function="linkURL">("mailto:robin@reportlab.com",)</plugInFlowable>
58
<td destination="BACK_PAGE">Internal link to back page</td>
59
<td href="http://www.reportlab.com/">Hyperlink to www.reportlab.com</td>
64
<para>This should be a 5x5 table where some ranges span. Note that the grid and background
65
commands still work on the "underlying" grid; if you grid the whole table, it will show through
66
your 'spanned cells' </para>
68
<blockTable colWidths="3cm,3cm,3cm,3cm,3cm" rowHeights="1cm,1cm,1cm,1cm,1cm" style="span001">
71
<para>This should span the first 3 cells in the top row. It's ordinary left aligned
72
text but could be centred if you want.</para>
78
<para>This should span all five cells in the right column. We vertically centred the
79
text to make it look sensible using a separate stylesheet command.</para>
81
<para>some more text</para>
113
<spacer length="24"/>
114
<para>This should be a 5x5 table where some ranges span. The column widths have been set as
115
3cm,10%,10%,10%,30%. The percentage refers to unallocated width only.
117
<spacer length="12"/>
118
<blockTable colWidths="3cm,10%,10%,10%,30%" rowHeights="2cm,1cm,1cm,1cm,None" style="span001">
121
<para>This should span the first 3 cells in the top row. It's ordinary left aligned
122
text but could be centred if you want.</para>
127
<td leftPadding="0" rightPadding="0">
128
<para>This should span all five cells in the right column. We vertically centred the
129
text to make it look sensible using a separate stylesheet command.</para>
130
<hr spaceBefore="1" width="100%" thickness="1.5" color="pink"/>
131
<hr spaceBefore="1" width="100%" thickness="1.5" color="pink" lineCap="butt"/>
132
<hr spaceBefore="1" width="100%" thickness="1.5" color="pink" lineCap="square"/>
133
<hr spaceBefore="1" width="50%" thickness="1.5" color="pink" lineCap="square" align="right"/>
134
<hr spaceBefore="1" width="50%" thickness="1.5" color="pink" lineCap="square" align="left"/>
135
<hr spaceBefore="1" width="50%" thickness="1.5" color="pink" lineCap="square" align="centre"/>
136
<para>some more text</para>
168
<spacer length="24"/>
170
<bookmark name="PAGE_TWO"/>
171
<para>This shows some pointers on doing financial tables. It demonstrates the decimal alignment and
172
multiple lines. We also used a local <td color="red"> attribute for the negative cell; ideally one wants to make the data drive the colour,
173
so that generator apps don't need to make para tags in every cell if they want red negatives.
174
If we move to dynamic RML, then a number-and-cell-formatting function is possible, but static RML
175
sees everything as text.
177
Note that when the value does not contain the decimal character but there are non-digit characters at the
178
end, it tries to align the rightmost digits with other rows.
180
<spacer length="12"/>
181
<blockTable colWidths="8cm,4cm">
182
<blockTableStyle id="temp003">
183
<!--top row - centre and bold, easy-->
184
<blockFont name="Times-Bold" start="0,0" stop="-1,0"/>
185
<blockAlignment value="center" start="0,0" stop="-1,0"/>
186
<lineStyle kind="LINEABOVE" colorName="purple" start="0,0" stop="-1,0"/>
187
<lineStyle kind="LINEBELOW" colorName="purple" start="0,0" stop="-1,0"/>
188
<!--numeric region - decimal align and set right padding-->
189
<blockAlignment value="decimal" start="1,1" stop="-1,-1"/>
190
<blockRightPadding length="1.5cm" start="1,1" stop="-1,-1"/>
191
<blockTextColor colorName="red" start="1,-2" stop="1,-2"/>
192
<!--bottom row - double underline-->
193
<blockFont name="Times-Bold" start="0,-1" stop="-1,-1"/>
194
<lineStyle kind="LINEABOVE" colorName="purple" start="0,-1" stop="-1,-1"/>
195
<lineStyle kind="LINEBELOW" colorName="purple" start="0,-1" stop="-1,-1" count="2"/>
198
<td>Corporate Assets</td>
202
<td>Fixed Assets</td>
203
<td>1,234,567.89</td>
206
<td>Legal Offense Fund</td>
210
<td>Company Vehicle</td>
218
<td>Intellectual Property</td>
219
<td>Questionable</td>
222
<td>Bank Overdraft</td>
223
<td fontColor="red">(13,029)</td>
227
<td fontColor="red">(742,078,231.56)</td>
230
<td>Flat Screen TV</td>
231
<td fontColor="red">27 inches</td>
234
<td>Net Position</td>
235
<td>Doomed. Really!</td>
239
<para>Individual <td> tags that contain pure strings can override the following attributes:
240
<font face="Courier-Bold" size="9">fontName, fontSize, fontColor, leading, leftPadding, rightPadding,
241
topPadding, bottomPadding, background, align, vAlign,
242
lineBelowThickness, lineBelowColor, lineBelowCap, lineBelowCount, lineBelowSpace,
243
lineAboveThickness, lineAboveColor, lineAboveCap, lineAboveCount, lineAboveSpace,
244
lineLeftThickness, lineLeftColor, lineLeftCap, lineLeftCount, lineLeftSpace,
245
lineRightThickness, lineRightColor, lineRightCap, lineRightCount, lineRightSpace
247
<spacer length="24"/>
248
<blockTable colWidths="5cm,5cm" style="temp001">
251
<td fontName="Courier">Courier</td>
255
<td fontName="Helvetica">Helvetica</td>
259
<td fontSize="8">8</td>
263
<td fontSize="14">14</td>
267
<td fontColor="red">red</td>
271
<td fontColor="blue">blue</td>
275
<td leading="16">leading
281
<td leading="12">leading
287
<td leftPadding="10">10</td>
291
<td leftPadding="16">16</td>
294
<td>rightPadding</td>
295
<td rightPadding="10" align="right">10</td>
298
<td>rightPadding</td>
299
<td rightPadding="24" align="right">24</td>
303
<td topPadding="10">10</td>
307
<td topPadding="24">24</td>
310
<td>bottomPadding</td>
311
<td bottomPadding="10">10</td>
314
<td>bottomPadding</td>
315
<td bottomPadding="24">24</td>
319
<td background="pink">pink</td>
323
<td background="lightblue">lightblue</td>
327
<td align="left">left</td>
331
<td align="center">center</td>
335
<td align="right">right</td>
341
<td vAlign="top">top</td>
347
<td vAlign="middle">middle</td>
353
<td vAlign="bottom">bottom</td>
357
<td lineBelowThickness="1" lineBelowColor="red">right</td>
361
<para>This table is using <b><xpre></b> tags around the contents of the right hand column.</para>
362
<spacer length="24"/>
363
<blockTable colWidths="5cm,5cm" style="temp001">
366
<td fontName="Courier">
372
<td fontName="Helvetica">
373
<xpre>Helvetica</xpre>
396
<td fontColor="blue">
418
<td leftPadding="10">
424
<td leftPadding="16">
429
<td>rightPadding</td>
430
<td rightPadding="10" align="right">
435
<td>rightPadding</td>
436
<td rightPadding="24" align="right">
453
<td>bottomPadding</td>
454
<td bottomPadding="10">
459
<td>bottomPadding</td>
460
<td bottomPadding="24">
466
<td background="pink">
472
<td background="lightblue">
473
<xpre>lightblue</xpre>
520
<h2>Bulk Data Support</h2>
521
<para>Very often one wants to get quite a lot of text or numeric data into a table - for
522
example from a database query or imported data file. Quoting all of this correctly as
523
XML and wrapping in in td and tr tags is time and memory consumuing, unquoting and parsing it
524
all back even more so. Therefore, instead of explicitly creating row and cell tags, you
525
can now use a new <b>bulkData</b> tag. This lets you specify a delimiter for fields (default
526
is comma) and for records (default is newline), and rml2pdf will break this up.</para>
527
<para>If you want to avoid having to quote ampersands, wrap this in a CDATA escape sequence.</para>
528
<para>Of course if you want per-cell formatting or to put arbitrary flowables in a cell, you
529
must use the other tags.</para>
530
<spacer length="24"/>
531
<blockTable style="numeric">
541
<spacer length="24"/>
542
<para>You can specify a tab with <b>fieldDelim="\t"</b>, but we generally advise against using any
543
whitespace character as a delimiter if you have a choice. You can also specify fine-grained
544
"stripping" control; the default behaviour
545
is to strip whitespace off the top and bottom of the overall data block, so blank lines are
546
excluded, and off the ends of each row so line endings and indentation don't matter, but not off each
547
cell. Note that the strings in the cells may contain spaces
548
and these spaces will be respected in formatting. You are also advised to use a CDATA
549
escape sequence around your data so that "&","<" and ">", characters don't
550
need special handling.</para>
551
<h2>Excel Bulk Data Support</h2>
552
<para>The <b>excelData</b> tag is very similar to the bulk data support, but reads the bulk
553
data from an Excel file instead of from delimited textual data. The <b>range</b> attribute is
555
<spacer length="24"/>
556
<h3><font color="red">
557
Sorry Ecel Bulk Support is not yet here
560
<blockTable style="numeric">
561
<excelData fileName="exceldata.xls" sheetName="Sheet1" range="A1:B7" />
564
<spacer length="24"/>
565
<h2>Colour cycles by rows and columns</h2>
566
<para>It's sometimes nice to alternate colours by row (e.g. a pale color then
567
white) to visually break up a long table. The style lets you specify <b>cycles</b> as
568
well as single colours. Here we have created a style command which cycles through
569
pale green and white, like old stacks of fanfold paper...</para>
570
<blockTable align="LEFT">
571
<blockTableStyle id="repeater" spaceBefore="12">
572
<lineStyle kind="OUTLINE" colorName="black" thickness="0.5"/>
573
<blockFont name="Times-Bold" size="6" leading="7" start="0,0" stop="-1,0"/>
574
<blockBottomPadding length="1"/>
575
<blockBackground colorName="0xD0D0D0" start="0,0" stop="-1,0"/>
576
<lineStyle kind="LINEBELOW" colorName="black" start="0,0" stop="-1,0" thickness="0.5"/>
578
<blockFont name="Times-Roman" size="6" leading="7" start="0,1" stop="-1,-1"/>
579
<blockTopPadding length="1" start="0,1" stop="-1,-1"/>
580
<blockBackground colorsByRow="0xD0FFD0;None" start="0,1" stop="-1,-1"/>
590
<td>Expensive lunch with clients</td>
596
<td>Expensive lunch with clients</td>
602
<td>Expensive lunch with clients</td>
608
<td>Expensive lunch with clients</td>
614
<td>Expensive lunch with clients</td>
620
<td>Expensive lunch with clients</td>
626
<td>Expensive lunch with clients</td>
632
<td>Expensive lunch with clients</td>
638
<td>Expensive lunch with clients</td>
644
<td>Expensive lunch with clients</td>
650
<td>Expensive lunch with clients</td>
656
<td>Expensive lunch with clients</td>
662
<td>Expensive lunch with clients</td>
668
<td>Expensive lunch with clients</td>
674
<td>Expensive lunch with clients</td>
680
<td>Expensive lunch with clients</td>
686
<td>Expensive lunch with clients</td>
692
<td>Expensive lunch with clients</td>
698
<td>Expensive lunch with clients</td>
704
<td>Expensive lunch with clients</td>
710
<td>Bottom row should be greem</td>
716
<para>Try again by column, with three colors this time. Also ensure some row heights
717
vary to check accuracy of drawing.</para>
718
<blockTable align="RIGHT">
719
<blockTableStyle id="repeater2" spaceBefore="12">
720
<lineStyle kind="OUTLINE" colorName="black" thickness="0.5"/>
721
<lineStyle kind="GRID" colorName="gray" thickness="0.25"/>
722
<blockFont name="Times-Bold" size="6" leading="7" start="0,0" stop="-1,0"/>
723
<blockBottomPadding length="1"/>
724
<blockBackground colorName="0xD0D0D0" start="0,0" stop="-1,0"/>
725
<lineStyle kind="LINEBELOW" colorName="black" start="0,0" stop="-1,0" thickness="0.5"/>
727
<blockFont name="Times-Roman" size="6" leading="7" start="0,1" stop="-1,-1"/>
728
<blockTopPadding length="1" start="0,1" stop="-1,-1"/>
729
<blockBackground colorsByRow="0xD0FFD0;0xFFD0FF;None" start="0,1" stop="-1,-1"/>
739
<td>Expensive lunch with clients</td>
745
<td>Expensive lunch with clients</td>
751
<td>Expensive lunch with clients
752
plus magnum of champagne</td>
758
<td>Expensive lunch with clients</td>
764
<td>Expensive lunch with clients</td>
770
<td>Expensive lunch with clients</td>
776
<td>Expensive lunch with clients</td>
782
<td>Expensive lunch with clients</td>
788
<td>Expensive lunch with clients</td>
793
<para>And now by column (although this may be used less...)</para>
795
<blockTableStyle id="repeater3" spaceBefore="12">
796
<lineStyle kind="OUTLINE" colorName="black" thickness="0.5"/>
797
<lineStyle kind="GRID" colorName="gray" thickness="0.25"/>
798
<blockFont name="Times-Bold" size="6" leading="7" start="0,0" stop="-1,0"/>
799
<blockBottomPadding length="1"/>
800
<blockBackground colorName="0xD0D0D0" start="0,0" stop="-1,0"/>
801
<lineStyle kind="LINEBELOW" colorName="black" start="0,0" stop="-1,0" thickness="0.5"/>
803
<blockFont name="Times-Roman" size="6" leading="7" start="0,1" stop="-1,-1"/>
804
<blockTopPadding length="1" start="0,1" stop="-1,-1"/>
805
<blockBackground colorsByCol="0xD0FFD0;None" start="0,1" stop="-1,-1"/>
826
<td>Entertainment</td>
843
<td>Entertainment</td>
860
<td>Entertainment</td>
877
<td>Entertainment</td>
894
<td>Entertainment</td>
912
<h2>Splitting over pages - top and bottom rows</h2>
913
<para>Sometimes a table splits over a page and you don't have a grid, so the bottom part (and top of the
914
new page) have no line boxing them in. The splitfirst and splilast magic coordinates can be used to insert
915
a line drawing routine into the style for this. I used an ugly thick purple line!</para>
916
<blockTable repeatRows="1">
917
<blockTableStyle id="repeater" spaceBefore="12">
918
<lineStyle kind="OUTLINE" colorName="black" thickness="0.5"/>
919
<blockFont name="Times-Bold" size="6" leading="7" start="0,0" stop="-1,0"/>
920
<blockBottomPadding length="1"/>
921
<blockBackground colorName="0xD0D0D0" start="0,0" stop="-1,0"/>
922
<lineStyle kind="LINEBELOW" colorName="black" start="0,0" stop="-1,0" thickness="0.5"/>
924
<blockFont name="Times-Roman" size="6" leading="7" start="0,1" stop="-1,-1"/>
925
<blockTopPadding length="1" start="0,1" stop="-1,-1"/>
926
<blockBackground colorsByRow="0xD0FFD0;None" start="0,1" stop="-1,-1"/>
927
<blockAlignment value="right" start="1,1" stop="-1,-1"/>
929
<!-- ensure the bottom of the table is 'closed off' during the split. I've used an ugly red dashed line -->
930
<lineStyle kind="LINEBELOW" colorName="purple" start="0,splitlast" stop="-1,splitlast" thickness="3"/>
934
<tr> <td>Date</td><td>Item</td><td>Debit</td><td>Credit</td></tr>
935
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
936
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
937
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
938
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
939
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
940
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
941
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
942
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
943
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
944
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
945
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
946
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
947
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
948
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
949
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
950
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
951
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
952
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
953
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
954
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
955
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
956
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
957
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
958
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
959
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
960
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
961
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
962
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
963
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
964
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
965
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
966
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
967
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
968
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
969
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
970
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
971
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
972
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
973
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
974
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
975
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
976
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
977
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
978
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
979
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
980
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
981
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
982
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
983
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
984
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
985
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
986
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
987
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100</td><td>-</td></tr>
988
<tr> <td>28-09-2004</td><td>Expensive lunch with clients</td><td>100 </td><td>-</td></tr>
992
<bookmark name="BACK_PAGE"/>