author | rgbecker |
Wed, 12 Jul 2000 09:05:17 +0000 | |
changeset 354 | 807513dd52b7 |
parent 350 | 0916ae478b25 |
child 356 | 377367fe28cb |
permissions | -rwxr-xr-x |
6 | 1 |
############################################################################### |
2 |
# |
|
3 |
# ReportLab Public License Version 1.0 |
|
4 |
# |
|
326 | 5 |
# Except for the change of names the spirit and intention of this |
6 |
# license is the same as that of Python |
|
6 | 7 |
# |
8 |
# (C) Copyright ReportLab Inc. 1998-2000. |
|
9 |
# |
|
10 |
# |
|
11 |
# All Rights Reserved |
|
12 |
# |
|
13 |
# Permission to use, copy, modify, and distribute this software and its |
|
14 |
# documentation for any purpose and without fee is hereby granted, provided |
|
15 |
# that the above copyright notice appear in all copies and that both that |
|
16 |
# copyright notice and this permission notice appear in supporting |
|
7 | 17 |
# documentation, and that the name of ReportLab not be used |
6 | 18 |
# in advertising or publicity pertaining to distribution of the software |
19 |
# without specific, written prior permission. |
|
20 |
# |
|
21 |
# |
|
22 |
# Disclaimer |
|
23 |
# |
|
24 |
# ReportLab Inc. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS |
|
25 |
# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, |
|
26 |
# IN NO EVENT SHALL ReportLab BE LIABLE FOR ANY SPECIAL, INDIRECT |
|
27 |
# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS |
|
28 |
# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR |
|
29 |
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
|
30 |
# PERFORMANCE OF THIS SOFTWARE. |
|
31 |
# |
|
32 |
############################################################################### |
|
33 |
# $Log: tables.py,v $ |
|
354 | 34 |
# Revision 1.21 2000/07/12 09:05:17 rgbecker |
35 |
# Fixed tuple size bug |
|
36 |
# |
|
350 | 37 |
# Revision 1.20 2000/07/11 14:29:45 rgbecker |
38 |
# Table splitting start |
|
354 | 39 |
# |
342 | 40 |
# Revision 1.19 2000/07/10 15:25:47 andy_robinson |
41 |
# Added tables to PythonPoint |
|
350 | 42 |
# |
338 | 43 |
# Revision 1.18 2000/07/08 15:30:04 rgbecker |
44 |
# Cosmetics and error testing |
|
342 | 45 |
# |
333 | 46 |
# Revision 1.17 2000/07/07 16:22:10 rgbecker |
47 |
# Fix auto hieght stuff |
|
338 | 48 |
# |
329 | 49 |
# Revision 1.16 2000/07/07 10:23:36 rgbecker |
50 |
# First attempt at VALIGN |
|
333 | 51 |
# |
329 | 52 |
# Revision 1.15 2000/07/06 14:05:55 rgbecker |
327 | 53 |
# Adjusted doc string |
329 | 54 |
# |
55 |
# Revision 1.14 2000/07/06 12:41:47 rgbecker |
|
326 | 56 |
# First try at auto sizing |
327 | 57 |
# |
326 | 58 |
# Revision 1.13 2000/06/29 17:55:19 aaron_watters |
312 | 59 |
# support explicit \n line splitting in cells |
326 | 60 |
# |
61 |
# Revision 1.12 2000/06/13 13:03:31 aaron_watters |
|
268 | 62 |
# more documentation changes |
312 | 63 |
# |
326 | 64 |
# Revision 1.11 2000/06/01 15:23:06 rgbecker |
253 | 65 |
# Platypus re-organisation |
268 | 66 |
# |
326 | 67 |
# Revision 1.10 2000/05/26 09:49:23 rgbecker |
248 | 68 |
# Color fixes; thanks to J Alet |
253 | 69 |
# |
221 | 70 |
# Revision 1.9 2000/05/16 16:15:16 rgbecker |
71 |
# Changes related to removal of SimpleFlowDocument |
|
248 | 72 |
# |
168
02bac1346c69
Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents:
129
diff
changeset
|
73 |
# Revision 1.8 2000/04/26 11:07:15 andy_robinson |
02bac1346c69
Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents:
129
diff
changeset
|
74 |
# Tables changed to use reportlab.lib.colors instead of |
02bac1346c69
Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents:
129
diff
changeset
|
75 |
# the six hard-coded color strings there previously. |
221 | 76 |
# |
129 | 77 |
# Revision 1.7 2000/04/14 12:17:05 rgbecker |
78 |
# Splitting layout.py |
|
168
02bac1346c69
Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents:
129
diff
changeset
|
79 |
# |
128 | 80 |
# Revision 1.6 2000/04/14 11:54:57 rgbecker |
81 |
# Splitting layout.py |
|
129 | 82 |
# |
122 | 83 |
# Revision 1.5 2000/04/14 08:56:20 rgbecker |
84 |
# Drawable ==> Flowable |
|
128 | 85 |
# |
16 | 86 |
# Revision 1.4 2000/02/17 02:09:05 rgbecker |
87 |
# Docstring & other fixes |
|
122 | 88 |
# |
7 | 89 |
# Revision 1.3 2000/02/15 17:55:59 rgbecker |
90 |
# License text fixes |
|
16 | 91 |
# |
6 | 92 |
# Revision 1.2 2000/02/15 15:47:09 rgbecker |
93 |
# Added license, __version__ and Logi comment |
|
7 | 94 |
# |
354 | 95 |
__version__=''' $Id: tables.py,v 1.21 2000/07/12 09:05:17 rgbecker Exp $ ''' |
16 | 96 |
__doc__=""" |
6 | 97 |
Tables are created by passing the constructor a tuple of column widths, a tuple of row heights and the data in |
98 |
row order. Drawing of the table can be controlled by using a TableStyle instance. This allows control of the |
|
99 |
color and weight of the lines (if any), and the font, alignment and padding of the text. |
|
268 | 100 |
|
327 | 101 |
None values in the sequence of row heights or column widths, mean that the corresponding rows |
102 |
or columns should be automatically sized. |
|
103 |
||
104 |
All the cell values should be convertible to strings; embedded newline '\\n' characters |
|
105 |
cause the value to wrap (ie are like a traditional linefeed). |
|
106 |
||
268 | 107 |
See the test output from running this module as a script for a discussion of the method for constructing |
108 |
tables and table styles. |
|
6 | 109 |
""" |
253 | 110 |
from reportlab.platypus import * |
129 | 111 |
from reportlab.lib.styles import PropertySet, getSampleStyleSheet |
168
02bac1346c69
Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents:
129
diff
changeset
|
112 |
from reportlab.lib import colors |
253 | 113 |
from reportlab.lib.pagesizes import DEFAULT_PAGE_SIZE |
312 | 114 |
import operator, string |
6 | 115 |
|
116 |
_stringtype = type('') |
|
117 |
||
128 | 118 |
class CellStyle(PropertySet): |
326 | 119 |
defaults = { |
120 |
'fontname':'Times-Roman', |
|
121 |
'fontsize':10, |
|
122 |
'leading':12, |
|
123 |
'leftPadding':6, |
|
124 |
'rightPadding':6, |
|
125 |
'topPadding':3, |
|
126 |
'bottomPadding':3, |
|
127 |
'firstLineIndent':0, |
|
128 |
'color':colors.black, |
|
129 |
'alignment': 'LEFT', |
|
130 |
'background': (1,1,1), |
|
329 | 131 |
'valign': 'BOTTOM', |
326 | 132 |
} |
6 | 133 |
|
134 |
class TableStyle: |
|
326 | 135 |
def __init__(self, cmds=None): |
136 |
self._cmds = cmds |
|
137 |
if cmds is None: |
|
138 |
self._cmds = [] |
|
139 |
def add(self, *cmd): |
|
140 |
self._cmds.append(cmd) |
|
141 |
def getCommands(self): |
|
142 |
return self._cmds |
|
338 | 143 |
|
144 |
TableStyleType = type(TableStyle()) |
|
326 | 145 |
|
221 | 146 |
class Table(Flowable): |
350 | 147 |
def __init__(self, colWidths, rowHeights, data, style=None, |
148 |
repeatRows=0, repeatCols=0, splitByRow=1): |
|
326 | 149 |
if not colWidths: |
150 |
raise ValueError, "Table must have at least 1 column" |
|
151 |
if not rowHeights: |
|
152 |
raise ValueError, "Table must have at least 1 row" |
|
153 |
nrows = self._nrows = len(rowHeights) |
|
154 |
if len(data) != nrows: |
|
155 |
raise ValueError, "Data error - %d rows in data but %d in grid" % (len(data), nrows) |
|
156 |
ncols = self._ncols = len(colWidths) |
|
157 |
for i in range(nrows): |
|
158 |
if len(data[i]) != ncols: |
|
159 |
raise ValueError, "Not enough data points in row %d!" % i |
|
350 | 160 |
self._rowHeights = self._argH = rowHeights |
161 |
self._colWidths = self._argW = colWidths |
|
326 | 162 |
self._cellvalues = data |
163 |
dflt = CellStyle('<default>') |
|
350 | 164 |
|
165 |
self._cellStyles = [None]*nrows |
|
326 | 166 |
for i in range(nrows): |
350 | 167 |
self._cellStyles[i] = [dflt]*ncols |
168 |
||
326 | 169 |
self._bkgrndcmds = [] |
170 |
self._linecmds = [] |
|
171 |
self._curweight = self._curcolor = self._curcellstyle = None |
|
350 | 172 |
self.repeatRows = repeatRows |
173 |
self.repeatCols = repeatCols |
|
174 |
self.splitByRow = splitByRow |
|
6 | 175 |
|
342 | 176 |
if style: |
177 |
self.setStyle(style) |
|
178 |
||
326 | 179 |
def _calc(self): |
333 | 180 |
|
350 | 181 |
H = self._argH |
182 |
W = self._argW |
|
6 | 183 |
|
326 | 184 |
if None in H: |
185 |
H = H[:] #make a copy as we'll change it |
|
333 | 186 |
self._rowHeights = H |
326 | 187 |
while None in H: |
188 |
i = H.index(None) |
|
189 |
V = self._cellvalues[i] |
|
350 | 190 |
S = self._cellStyles[i] |
326 | 191 |
h = 0 |
192 |
for v, s in map(None, V, S): |
|
193 |
if type(v) is not _stringtype: v = str(v) |
|
194 |
v = string.split(v, "\n") |
|
195 |
t = s.leading*len(v)+s.bottomPadding+s.topPadding |
|
196 |
if t>h: h = t #record a new maximum |
|
197 |
H[i] = h |
|
6 | 198 |
|
326 | 199 |
if None in W: |
200 |
W = W[:] |
|
201 |
self._colWidths = W |
|
202 |
while None in W: |
|
203 |
i = W.index(None) |
|
204 |
f = lambda x,i=i: operator.getitem(x,i) |
|
205 |
V = map(f,self._cellvalues) |
|
350 | 206 |
S = map(f,self._cellStyles) |
326 | 207 |
w = 0 |
208 |
for v, s in map(None, V, S): |
|
209 |
if type(v) is not _stringtype: v = str(v) |
|
210 |
v = string.split(v, "\n") |
|
211 |
t = s.leftPadding+s.rightPadding + max(map(lambda a, b=s.fontname, |
|
212 |
c=s.fontsize,d=self.canv: d.stringWidth(a,b,c), v)) |
|
213 |
if t>w: w = t #record a new maximum |
|
214 |
W[i] = w |
|
6 | 215 |
|
0 | 216 |
|
326 | 217 |
height = self._height = reduce(operator.add, H, 0) |
218 |
self._rowpositions = [height] # index 0 is actually topline; we skip when processing cells |
|
219 |
for h in H: |
|
220 |
height = height - h |
|
221 |
self._rowpositions.append(height) |
|
329 | 222 |
assert abs(height)<1e-8, 'Internal height error' |
326 | 223 |
width = 0 |
224 |
self._colpositions = [0] #index -1 is right side boundary; we skip when processing cells |
|
225 |
for w in W: |
|
226 |
width = width + w |
|
227 |
self._colpositions.append(width) |
|
228 |
self._width = width |
|
6 | 229 |
|
326 | 230 |
def setStyle(self, tblstyle): |
338 | 231 |
if type(tblstyle) is not TableStyleType: |
232 |
tblstyle = TableStyle(tblstyle) |
|
326 | 233 |
for cmd in tblstyle.getCommands(): |
350 | 234 |
self._addCommand(cmd) |
235 |
||
236 |
def _addCommand(self,cmd): |
|
237 |
if cmd[0] == 'BACKGROUND': |
|
238 |
self._bkgrndcmds.append(cmd) |
|
239 |
elif _isLineCommand(cmd): |
|
240 |
self._linecmds.append(cmd) |
|
241 |
else: |
|
242 |
(op, (sc, sr), (ec, er)), values = cmd[:3] , cmd[3:] |
|
243 |
if sc < 0: sc = sc + self._ncols |
|
244 |
if ec < 0: ec = ec + self._ncols |
|
245 |
if sr < 0: sr = sr + self._nrows |
|
246 |
if er < 0: er = er + self._nrows |
|
247 |
for i in range(sr, er+1): |
|
248 |
for j in range(sc, ec+1): |
|
249 |
_setCellStyle(self._cellStyles, i, j, op, values) |
|
326 | 250 |
|
251 |
def _drawLines(self): |
|
252 |
for op, (sc, sr), (ec, er), weight, color in self._linecmds: |
|
253 |
if sc < 0: sc = sc + self._ncols |
|
254 |
if ec < 0: ec = ec + self._ncols |
|
255 |
if sr < 0: sr = sr + self._nrows |
|
256 |
if er < 0: er = er + self._nrows |
|
257 |
if op == 'GRID': |
|
258 |
self._drawBox( (sc, sr), (ec, er), weight, color) |
|
259 |
self._drawInnerGrid( (sc, sr), (ec, er), weight, color) |
|
260 |
elif op in ('BOX', 'OUTLINE',): |
|
261 |
self._drawBox( (sc, sr), (ec, er), weight, color) |
|
262 |
elif op == 'INNERGRID': |
|
263 |
self._drawInnerGrid( (sc, sr), (ec, er), weight, color) |
|
264 |
elif op == 'LINEBELOW': |
|
265 |
self._drawHLines((sc, sr+1), (ec, er+1), weight, color) |
|
266 |
elif op == 'LINEABOVE': |
|
267 |
self._drawHLines((sc, sr), (ec, er), weight, color) |
|
268 |
elif op == 'LINEBEFORE': |
|
269 |
self._drawVLines((sc, sr), (ec, er), weight, color) |
|
270 |
elif op == 'LINEAFTER': |
|
271 |
self._drawVLines((sc+1, sr), (ec+1, er), weight, color) |
|
272 |
else: |
|
273 |
raise ValueError, "Unknown line style %s" % op |
|
274 |
self._curcolor = None |
|
248 | 275 |
|
326 | 276 |
def _drawBox(self, (sc, sr), (ec, er), weight, color): |
277 |
self._drawHLines((sc, sr), (ec, sr), weight, color) |
|
278 |
self._drawHLines((sc, er+1), (ec, er+1), weight, color) |
|
279 |
self._drawVLines((sc, sr), (sc, er), weight, color) |
|
280 |
self._drawVLines((ec+1, sr), (ec+1, er), weight, color) |
|
350 | 281 |
|
326 | 282 |
def _drawInnerGrid(self, (sc, sr), (ec, er), weight, color): |
283 |
self._drawHLines((sc, sr+1), (ec, er), weight, color) |
|
284 |
self._drawVLines((sc+1, sr), (ec, er), weight, color) |
|
350 | 285 |
|
326 | 286 |
def _prepLine(self, weight, color): |
287 |
if color != self._curcolor: |
|
288 |
self.canv.setStrokeColor(color) |
|
289 |
self._curcolor = color |
|
290 |
if weight != self._curweight: |
|
291 |
self.canv.setLineWidth(weight) |
|
292 |
self._curweight = weight |
|
350 | 293 |
|
326 | 294 |
def _drawHLines(self, (sc, sr), (ec, er), weight, color): |
295 |
self._prepLine(weight, color) |
|
296 |
scp = self._colpositions[sc] |
|
297 |
ecp = self._colpositions[ec+1] |
|
298 |
for rowpos in self._rowpositions[sr:er+1]: |
|
299 |
self.canv.line(scp, rowpos, ecp, rowpos) |
|
350 | 300 |
|
326 | 301 |
def _drawVLines(self, (sc, sr), (ec, er), weight, color): |
302 |
self._prepLine(weight, color) |
|
303 |
srp = self._rowpositions[sr] |
|
304 |
erp = self._rowpositions[er+1] |
|
305 |
for colpos in self._colpositions[sc:ec+1]: |
|
306 |
self.canv.line(colpos, srp, colpos, erp) |
|
307 |
||
308 |
def wrap(self, availWidth, availHeight): |
|
309 |
self._calc() |
|
310 |
#nice and easy, since they are predetermined size |
|
311 |
self.availWidth = availWidth |
|
312 |
return (self._width, self._height) |
|
350 | 313 |
|
314 |
def _cr_0(self,n,cmds): |
|
354 | 315 |
for c in cmds: |
316 |
c = tuple(c) |
|
317 |
(sc,sr), (ec,er) = c[1:3] |
|
350 | 318 |
if sr>=n: continue |
319 |
if er>=n: er = n-1 |
|
354 | 320 |
self._addCommand((c[0],)+((sc, sr), (ec, er))+c[3:]) |
350 | 321 |
|
322 |
def _cr_1_1(self,n,repeatRows, cmds): |
|
354 | 323 |
for c in cmds: |
324 |
c = tuple(c) |
|
325 |
(sc,sr), (ec,er) = c[1:3] |
|
350 | 326 |
if sr>=0 and sr>=repeatRows and sr<n and er>=0 and er<n: continue |
327 |
if sr>=repeatRows and sr<n: sr=repeatRows |
|
328 |
elif sr>=repeatRows and sr>=n: sr=sr+repeatRows-n |
|
329 |
if er>=repeatRows and er<n: er=repeatRows |
|
330 |
elif er>=repeatRows and er>=n: er=er+repeatRows-n |
|
354 | 331 |
self._addCommand((c[0],)+((sc, sr), (ec, er))+c[3:]) |
350 | 332 |
|
333 |
def _cr_1_0(self,n,cmds): |
|
354 | 334 |
for c in cmds: |
335 |
c = tuple(c) |
|
336 |
(sc,sr), (ec,er) = c[1:3] |
|
350 | 337 |
if er>=0 and er<n: continue |
338 |
if sr>=0 and sr<n: sr=0 |
|
339 |
if sr>=n: sr = sr-n |
|
340 |
if er>=n: er = er-n |
|
354 | 341 |
self._addCommand((c[0],)+((sc, sr), (ec, er))+c[3:]) |
350 | 342 |
|
343 |
def _splitRows(self,availHeight): |
|
344 |
self._calc() |
|
345 |
h = 0 |
|
346 |
n = 0 |
|
347 |
lim = len(self._rowHeights) |
|
348 |
while n<lim: |
|
349 |
hn = h + self._rowHeights[n] |
|
350 |
if hn>availHeight: break |
|
351 |
h = hn |
|
352 |
n = n + 1 |
|
353 |
||
354 |
if n<=self.repeatRows: |
|
355 |
return [] |
|
356 |
||
357 |
if n==lim: return [self] |
|
358 |
||
359 |
repeatRows = self.repeatRows |
|
360 |
repeatCols = self.repeatCols |
|
361 |
splitByRow = self.splitByRow |
|
362 |
data = self._cellvalues |
|
363 |
||
364 |
#we're going to split into two superRows |
|
365 |
R0 = Table( self._argW, self._argH[:n], data[:n], |
|
366 |
repeatRows=repeatRows, repeatCols=repeatCols, |
|
367 |
splitByRow=splitByRow) |
|
368 |
||
369 |
#copy the styles and commands |
|
370 |
R0._cellStyles = self._cellStyles[:n] |
|
371 |
R0._cr_0(n,self._linecmds) |
|
372 |
R0._cr_0(n,self._bkgrndcmds) |
|
373 |
||
374 |
if repeatRows: |
|
375 |
R1 = Table(self._argW, self._argH[:repeatRows]+self._argH[n:], |
|
376 |
data[:repeatRows]+data[n:], |
|
377 |
repeatRows=repeatRows, repeatCols=repeatCols, |
|
378 |
splitByRow=splitByRow) |
|
379 |
R1._cellStyles = self._cellStyles[:repeatRows]+self._cellStyles[n:] |
|
380 |
R1._cr_1_1(n,repeatRows,self._linecmds) |
|
381 |
R1._cr_1_1(n,repeatRows,self._bkgrndcmds) |
|
382 |
else: |
|
383 |
R1 = Table(self._argW, self._argH[n:],data[n:], |
|
384 |
repeatRows=repeatRows, repeatCols=repeatCols, |
|
385 |
splitByRow=splitByRow) |
|
386 |
R1._cellStyles = self._cellStyles[n:] |
|
387 |
R1._cr_1_0(n,self._linecmds) |
|
388 |
R1._cr_1_0(n,self._bkgrndcmds) |
|
389 |
||
390 |
return [R0,R1] |
|
391 |
||
392 |
def split(self, availWidth, availHeight): |
|
393 |
if self.splitByRow: |
|
394 |
if self._width>availWidth: return [] |
|
395 |
return self._splitRows(availHeight) |
|
396 |
else: |
|
397 |
raise NotImplementedError |
|
398 |
||
326 | 399 |
|
400 |
def draw(self): |
|
401 |
nudge = 0.5 * (self.availWidth - self._width) |
|
402 |
self.canv.translate(nudge, 0) |
|
403 |
self._drawBkgrnd() |
|
404 |
self._drawLines() |
|
350 | 405 |
for row, rowstyle, rowpos, rowheight in map(None, self._cellvalues, self._cellStyles, self._rowpositions[1:], self._rowHeights): |
326 | 406 |
for cellval, cellstyle, colpos, colwidth in map(None, row, rowstyle, self._colpositions[:-1], self._colWidths): |
407 |
self._drawCell(cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)) |
|
408 |
||
409 |
def _drawBkgrnd(self): |
|
410 |
for cmd, (sc, sr), (ec, er), color in self._bkgrndcmds: |
|
411 |
if sc < 0: sc = sc + self._ncols |
|
412 |
if ec < 0: ec = ec + self._ncols |
|
413 |
if sr < 0: sr = sr + self._nrows |
|
414 |
if er < 0: er = er + self._nrows |
|
415 |
color = colors.toColor(color, colors.Color(1,1,1)) |
|
416 |
x0 = self._colpositions[sc] |
|
417 |
y0 = self._rowpositions[sr] |
|
418 |
x1 = self._colpositions[ec+1] |
|
419 |
y1 = self._rowpositions[er+1] |
|
420 |
self.canv.setFillColor(color) |
|
421 |
self.canv.rect(x0, y0, x1-x0, y1-y0,stroke=0,fill=1) |
|
422 |
||
423 |
def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): |
|
424 |
#print "cellstyle is ", repr(cellstyle), id(cellstyle) |
|
425 |
if self._curcellstyle is not cellstyle: |
|
426 |
cur = self._curcellstyle |
|
427 |
if cur is None or cellstyle.color != cur.color: |
|
428 |
#print "setting cell color to %s" % `cellstyle.color` |
|
429 |
self.canv.setFillColor(cellstyle.color) |
|
430 |
if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontname or cellstyle.fontsize != cur.fontsize: |
|
431 |
#print "setting font: %s, %s, %s" % (cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) |
|
432 |
self.canv.setFont(cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) |
|
433 |
self._curcellstyle = cellstyle |
|
434 |
#print "leading is ", cellstyle.leading, "size is", cellstyle.fontsize |
|
435 |
just = cellstyle.alignment |
|
436 |
#print "alignment is ", just |
|
437 |
if just == 'LEFT': |
|
438 |
draw = self.canv.drawString |
|
439 |
x = colpos + cellstyle.leftPadding |
|
440 |
elif just in ('CENTRE', 'CENTER'): |
|
441 |
draw = self.canv.drawCentredString |
|
442 |
x = colpos + colwidth * 0.5 |
|
338 | 443 |
elif just == 'RIGHT': |
326 | 444 |
draw = self.canv.drawRightString |
445 |
x = colpos + colwidth - cellstyle.rightPadding |
|
338 | 446 |
else: |
447 |
raise ValueError, 'Invalid justification %s' % just |
|
448 |
||
326 | 449 |
if type(cellval) is _stringtype: |
450 |
val = cellval |
|
451 |
else: |
|
452 |
val = str(cellval) |
|
453 |
vals = string.split(val, "\n") |
|
454 |
n = len(vals)-1 |
|
455 |
leading = cellstyle.leading |
|
329 | 456 |
valign = cellstyle.valign |
457 |
if valign=='BOTTOM': |
|
458 |
y = rowpos + cellstyle.bottomPadding+n*leading |
|
459 |
elif valign=='TOP': |
|
338 | 460 |
y = rowpos + rowheight - cellstyle.topPadding - cellstyle.fontsize |
329 | 461 |
elif valign=='MIDDLE': |
462 |
y = rowpos + (cellstyle.bottomPadding + rowheight - cellstyle.topPadding+n*leading)/2.0 |
|
463 |
else: |
|
464 |
raise ValueError, "Bad valign: '%s'" % str(valign) |
|
465 |
||
326 | 466 |
for v in vals: |
329 | 467 |
draw(x, y, v) |
468 |
y = y-leading |
|
326 | 469 |
|
6 | 470 |
# for text, |
326 | 471 |
# drawCentredString(self, x, y, text) where x is center |
472 |
# drawRightString(self, x, y, text) where x is right |
|
473 |
# drawString(self, x, y, text) where x is left |
|
6 | 474 |
|
475 |
LINECOMMANDS = ( |
|
326 | 476 |
'GRID', 'BOX', 'OUTLINE', 'INNERGRID', 'LINEBELOW', 'LINEABOVE', 'LINEBEFORE', 'LINEAFTER', ) |
6 | 477 |
|
478 |
||
479 |
def _isLineCommand(cmd): |
|
326 | 480 |
return cmd[0] in LINECOMMANDS |
6 | 481 |
|
350 | 482 |
def _setCellStyle(cellStyles, i, j, op, values): |
483 |
new = CellStyle('<%d, %d>' % (i,j), cellStyles[i][j]) |
|
484 |
cellStyles[i][j] = new |
|
326 | 485 |
if op == 'FONT': |
486 |
new.fontname = values[0] |
|
487 |
new.fontsize = values[1] |
|
488 |
elif op == 'TEXTCOLOR': |
|
489 |
new.color = colors.toColor(values[0], colors.Color(0,0,0)) |
|
490 |
elif op in ('ALIGN', 'ALIGNMENT'): |
|
491 |
new.alignment = values[0] |
|
329 | 492 |
elif op == 'VALIGN': |
493 |
new.valign = values[0] |
|
326 | 494 |
elif op == 'LEFTPADDING': |
495 |
new.leftPadding = values[0] |
|
496 |
elif op == 'RIGHTPADDING': |
|
497 |
new.rightPadding = values[0] |
|
498 |
elif op == 'TOPPADDING': |
|
499 |
new.topPadding = values[0] |
|
500 |
elif op == 'BOTTOMPADDING': |
|
501 |
new.bottomPadding = values[0] |
|
6 | 502 |
|
503 |
GRID_STYLE = TableStyle( |
|
326 | 504 |
[('GRID', (0,0), (-1,-1), 0.25, colors.black), |
505 |
('ALIGN', (1,1), (-1,-1), 'RIGHT')] |
|
506 |
) |
|
6 | 507 |
BOX_STYLE = TableStyle( |
326 | 508 |
[('BOX', (0,0), (-1,-1), 0.50, colors.black), |
509 |
('ALIGN', (1,1), (-1,-1), 'RIGHT')] |
|
510 |
) |
|
6 | 511 |
LABELED_GRID_STYLE = TableStyle( |
326 | 512 |
[('INNERGRID', (0,0), (-1,-1), 0.25, colors.black), |
513 |
('BOX', (0,0), (-1,-1), 2, colors.black), |
|
514 |
('LINEBELOW', (0,0), (-1,0), 2, colors.black), |
|
515 |
('LINEAFTER', (0,0), (0,-1), 2, colors.black), |
|
516 |
('ALIGN', (1,1), (-1,-1), 'RIGHT')] |
|
517 |
) |
|
6 | 518 |
COLORED_GRID_STYLE = TableStyle( |
326 | 519 |
[('INNERGRID', (0,0), (-1,-1), 0.25, colors.black), |
520 |
('BOX', (0,0), (-1,-1), 2, colors.red), |
|
521 |
('LINEBELOW', (0,0), (-1,0), 2, colors.black), |
|
522 |
('LINEAFTER', (0,0), (0,-1), 2, colors.black), |
|
523 |
('ALIGN', (1,1), (-1,-1), 'RIGHT')] |
|
524 |
) |
|
6 | 525 |
LIST_STYLE = TableStyle( |
326 | 526 |
[('LINEABOVE', (0,0), (-1,0), 2, colors.green), |
527 |
('LINEABOVE', (0,1), (-1,-1), 0.25, colors.black), |
|
528 |
('LINEBELOW', (0,-1), (-1,-1), 2, colors.green), |
|
529 |
('ALIGN', (1,1), (-1,-1), 'RIGHT')] |
|
530 |
) |
|
6 | 531 |
|
532 |
def test(): |
|
329 | 533 |
from reportlab.lib.units import inch |
326 | 534 |
rowheights = (24, 16, 16, 16, 16) |
535 |
rowheights2 = (24, 16, 16, 16, 30) |
|
536 |
colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32) |
|
537 |
data = ( |
|
538 |
('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), |
|
539 |
('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), |
|
540 |
('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), |
|
541 |
('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), |
|
542 |
('Hats', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') |
|
543 |
) |
|
544 |
data2 = ( |
|
545 |
('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), |
|
546 |
('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), |
|
547 |
('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), |
|
548 |
('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), |
|
549 |
('Hats\nLarge', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') |
|
550 |
) |
|
551 |
styleSheet = getSampleStyleSheet() |
|
552 |
lst = [] |
|
553 |
lst.append(Paragraph("Tables", styleSheet['Heading1'])) |
|
554 |
lst.append(Paragraph(__doc__, styleSheet['BodyText'])) |
|
555 |
lst.append(Paragraph("The Tables (shown in different styles below) were created using the following code:", styleSheet['BodyText'])) |
|
556 |
lst.append(Preformatted(""" |
|
557 |
colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32) |
|
558 |
rowheights = (24, 16, 16, 16, 16) |
|
559 |
data = ( |
|
560 |
('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', |
|
561 |
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), |
|
562 |
('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), |
|
563 |
('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), |
|
564 |
('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), |
|
565 |
('Hats', 893, 912, '1,212', 643, 789, 159, |
|
566 |
888, '1,298', 832, 453, '1,344','2,843') |
|
567 |
) |
|
568 |
t = Table(colwidths, rowheights, data) |
|
569 |
""", styleSheet['Code'], dedent=4)) |
|
570 |
lst.append(Paragraph(""" |
|
571 |
You can then give the Table a TableStyle object to control its format. The first TableStyle used was |
|
572 |
created as follows: |
|
573 |
""", styleSheet['BodyText'])) |
|
574 |
lst.append(Preformatted(""" |
|
6 | 575 |
GRID_STYLE = TableStyle( |
326 | 576 |
[('GRID', (0,0), (-1,-1), 0.25, colors.black), |
577 |
('ALIGN', (1,1), (-1,-1), 'RIGHT')] |
|
578 |
) |
|
579 |
""", styleSheet['Code'])) |
|
580 |
lst.append(Paragraph(""" |
|
581 |
TableStyles are created by passing in a list of commands. There are two types of commands - line commands |
|
582 |
and cell formatting commands. In all cases, the first three elements of a command are the command name, |
|
583 |
the starting cell and the ending cell. |
|
584 |
""", styleSheet['BodyText'])) |
|
585 |
lst.append(Paragraph(""" |
|
586 |
Line commands always follow this with the weight and color of the desired lines. Colors can be names, |
|
587 |
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 |
|
588 |
command names are: GRID, BOX, OUTLINE, INNERGRID, LINEBELOW, LINEABOVE, LINEBEFORE |
|
589 |
and LINEAFTER. BOX and OUTLINE are equivalent, and GRID is the equivalent of applying both BOX and |
|
590 |
INNERGRID. |
|
591 |
""", styleSheet['BodyText'])) |
|
592 |
lst.append(Paragraph(""" |
|
593 |
Cell formatting commands are: |
|
594 |
""", styleSheet['BodyText'])) |
|
595 |
lst.append(Paragraph(""" |
|
596 |
FONT - takes fontname, fontsize and (optional) leading. |
|
597 |
""", styleSheet['Definition'])) |
|
598 |
lst.append(Paragraph(""" |
|
599 |
TEXTCOLOR - takes a color name or (R,G,B) tuple. |
|
600 |
""", styleSheet['Definition'])) |
|
601 |
lst.append(Paragraph(""" |
|
602 |
ALIGNMENT (or ALIGN) - takes one of LEFT, RIGHT and CENTRE (or CENTER). |
|
603 |
""", styleSheet['Definition'])) |
|
604 |
lst.append(Paragraph(""" |
|
605 |
LEFTPADDING - defaults to 6. |
|
606 |
""", styleSheet['Definition'])) |
|
607 |
lst.append(Paragraph(""" |
|
608 |
RIGHTPADDING - defaults to 6. |
|
609 |
""", styleSheet['Definition'])) |
|
610 |
lst.append(Paragraph(""" |
|
611 |
BOTTOMPADDING - defaults to 3. |
|
612 |
""", styleSheet['Definition'])) |
|
613 |
lst.append(Paragraph(""" |
|
614 |
A tablestyle is applied to a table by calling Table.setStyle(tablestyle). |
|
615 |
""", styleSheet['BodyText'])) |
|
616 |
t = Table(colwidths, rowheights, data) |
|
617 |
t.setStyle(GRID_STYLE) |
|
618 |
lst.append(PageBreak()) |
|
619 |
lst.append(Paragraph("This is GRID_STYLE\n", styleSheet['BodyText'])) |
|
620 |
lst.append(t) |
|
621 |
||
622 |
t = Table(colwidths, rowheights, data) |
|
623 |
t.setStyle(BOX_STYLE) |
|
624 |
lst.append(Paragraph("This is BOX_STYLE\n", styleSheet['BodyText'])) |
|
625 |
lst.append(t) |
|
626 |
lst.append(Paragraph(""" |
|
627 |
It was created as follows: |
|
628 |
""", styleSheet['BodyText'])) |
|
629 |
lst.append(Preformatted(""" |
|
6 | 630 |
BOX_STYLE = TableStyle( |
326 | 631 |
[('BOX', (0,0), (-1,-1), 0.50, colors.black), |
632 |
('ALIGN', (1,1), (-1,-1), 'RIGHT')] |
|
633 |
) |
|
634 |
""", styleSheet['Code'])) |
|
635 |
||
636 |
t = Table(colwidths, rowheights, data) |
|
637 |
t.setStyle(LABELED_GRID_STYLE) |
|
638 |
lst.append(Paragraph("This is LABELED_GRID_STYLE\n", styleSheet['BodyText'])) |
|
639 |
lst.append(t) |
|
640 |
t = Table(colwidths, rowheights2, data2) |
|
641 |
t.setStyle(LABELED_GRID_STYLE) |
|
642 |
lst.append(Paragraph("This is LABELED_GRID_STYLE ILLUSTRATES EXPLICIT LINE SPLITTING WITH NEWLINE (different heights and data)\n", styleSheet['BodyText'])) |
|
643 |
lst.append(t) |
|
644 |
lst.append(Paragraph(""" |
|
645 |
It was created as follows: |
|
646 |
""", styleSheet['BodyText'])) |
|
647 |
lst.append(Preformatted(""" |
|
6 | 648 |
LABELED_GRID_STYLE = TableStyle( |
326 | 649 |
[('INNERGRID', (0,0), (-1,-1), 0.25, colors.black), |
650 |
('BOX', (0,0), (-1,-1), 2, colors.black), |
|
651 |
('LINEBELOW', (0,0), (-1,0), 2, colors.black), |
|
652 |
('LINEAFTER', (0,0), (0,-1), 2, colors.black), |
|
653 |
('ALIGN', (1,1), (-1,-1), 'RIGHT')] |
|
654 |
) |
|
655 |
""", styleSheet['Code'])) |
|
656 |
lst.append(PageBreak()) |
|
657 |
||
658 |
t = Table(colwidths, rowheights, data) |
|
659 |
t.setStyle(COLORED_GRID_STYLE) |
|
660 |
lst.append(Paragraph("This is COLORED_GRID_STYLE\n", styleSheet['BodyText'])) |
|
661 |
lst.append(t) |
|
662 |
lst.append(Paragraph(""" |
|
663 |
It was created as follows: |
|
664 |
""", styleSheet['BodyText'])) |
|
665 |
lst.append(Preformatted(""" |
|
6 | 666 |
COLORED_GRID_STYLE = TableStyle( |
326 | 667 |
[('INNERGRID', (0,0), (-1,-1), 0.25, colors.black), |
668 |
('BOX', (0,0), (-1,-1), 2, colors.red), |
|
669 |
('LINEBELOW', (0,0), (-1,0), 2, colors.black), |
|
670 |
('LINEAFTER', (0,0), (0,-1), 2, colors.black), |
|
671 |
('ALIGN', (1,1), (-1,-1), 'RIGHT')] |
|
672 |
) |
|
673 |
""", styleSheet['Code'])) |
|
674 |
||
675 |
t = Table(colwidths, rowheights, data) |
|
676 |
t.setStyle(LIST_STYLE) |
|
677 |
lst.append(Paragraph("This is LIST_STYLE\n", styleSheet['BodyText'])) |
|
678 |
lst.append(t) |
|
679 |
lst.append(Paragraph(""" |
|
680 |
It was created as follows: |
|
681 |
""", styleSheet['BodyText'])) |
|
682 |
lst.append(Preformatted(""" |
|
6 | 683 |
LIST_STYLE = TableStyle( |
326 | 684 |
[('LINEABOVE', (0,0), (-1,0), 2, colors.green), |
685 |
('LINEABOVE', (0,1), (-1,-1), 0.25, colors.black), |
|
686 |
('LINEBELOW', (0,-1), (-1,-1), 2, colors.green), |
|
687 |
('ALIGN', (1,1), (-1,-1), 'RIGHT')] |
|
688 |
) |
|
689 |
""", styleSheet['Code'])) |
|
6 | 690 |
|
326 | 691 |
t = Table(colwidths, rowheights, data) |
692 |
ts = TableStyle( |
|
693 |
[('LINEABOVE', (0,0), (-1,0), 2, colors.green), |
|
694 |
('LINEABOVE', (0,1), (-1,-1), 0.25, colors.black), |
|
695 |
('LINEBELOW', (0,-1), (-1,-1), 2, colors.green), |
|
696 |
('ALIGN', (1,1), (-1,-1), 'RIGHT'), |
|
697 |
('TEXTCOLOR', (0,1), (0,-1), colors.red), |
|
698 |
('BACKGROUND', (0,0), (-1,0), colors.Color(0,0.7,0.7))] |
|
699 |
) |
|
700 |
t.setStyle(ts) |
|
701 |
lst.append(Paragraph("This is a custom style\n", styleSheet['BodyText'])) |
|
702 |
lst.append(t) |
|
703 |
lst.append(Paragraph(""" |
|
704 |
It was created as follows: |
|
705 |
""", styleSheet['BodyText'])) |
|
706 |
lst.append(Preformatted(""" |
|
6 | 707 |
ts = TableStyle( |
326 | 708 |
[('LINEABOVE', (0,0), (-1,0), 2, colors.green), |
709 |
('LINEABOVE', (0,1), (-1,-1), 0.25, colors.black), |
|
710 |
('LINEBELOW', (0,-1), (-1,-1), 2, colors.green), |
|
711 |
('ALIGN', (1,1), (-1,-1), 'RIGHT'), |
|
712 |
('TEXTCOLOR', (0,1), (0,-1), colors.red), |
|
713 |
('BACKGROUND', (0,0), (-1,0), colors.Color(0,0.7,0.7))] |
|
714 |
) |
|
715 |
""", styleSheet['Code'])) |
|
716 |
data = ( |
|
717 |
('', 'Jan\nCold', 'Feb\n', 'Mar\n','Apr\n','May\n', 'Jun\nHot', 'Jul\n', 'Aug\nThunder', 'Sep\n', 'Oct\n', 'Nov\n', 'Dec\n'), |
|
718 |
('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), |
|
719 |
('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), |
|
720 |
('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), |
|
721 |
('Hats', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') |
|
722 |
) |
|
723 |
c = list(colwidths) |
|
724 |
c[0] = None |
|
725 |
c[8] = None |
|
726 |
t = Table(c, [None]+list(rowheights[1:]), data) |
|
727 |
t.setStyle(LIST_STYLE) |
|
728 |
lst.append(Paragraph(""" |
|
729 |
This is a LIST_STYLE table with the first rowheight set to None ie automatic. |
|
730 |
The top row cells are split at a newline '\\n' character. The first and August |
|
731 |
column widths were also set to None. |
|
732 |
""", styleSheet['BodyText'])) |
|
733 |
lst.append(t) |
|
329 | 734 |
lst.append(Paragraph(""" |
735 |
The red numbers should be aligned LEFT & BOTTOM, the blue RIGHT & TOP |
|
736 |
and the green CENTER & MIDDLE. |
|
737 |
""", styleSheet['BodyText'])) |
|
338 | 738 |
data= [['X00y', 'X01y', 'X02y', 'X03y', 'X04y'], |
739 |
['X10y', 'X11y', 'X12y', 'X13y', 'X14y'], |
|
740 |
['X20y', 'X21y', 'X22y', 'X23y', 'X24y'], |
|
741 |
['X30y', 'X31y', 'X32y', 'X33y', 'X34y']] |
|
329 | 742 |
t=Table(5*[0.4*inch], 4*[0.4*inch], data) |
338 | 743 |
t.setStyle([('ALIGN',(1,1),(-2,-2),'LEFT'), |
744 |
('TEXTCOLOR',(1,1),(-2,-2),colors.red), |
|
745 |
||
746 |
('VALIGN',(0,0),(1,-1),'TOP'), |
|
747 |
('ALIGN',(0,0),(1,-1),'RIGHT'), |
|
748 |
('TEXTCOLOR',(0,0),(1,-1),colors.blue), |
|
749 |
||
750 |
('ALIGN',(0,-1),(-1,-1),'CENTER'), |
|
751 |
('VALIGN',(0,-1),(-1,-1),'MIDDLE'), |
|
752 |
('TEXTCOLOR',(0,-1),(-1,-1),colors.green), |
|
753 |
||
754 |
('INNERGRID', (0,0), (-1,-1), 0.25, colors.black), |
|
755 |
('BOX', (0,0), (-1,-1), 0.25, colors.black), |
|
756 |
]) |
|
329 | 757 |
lst.append(t) |
333 | 758 |
data = [('alignment', 'align\012alignment'), |
759 |
('bulletColor', 'bulletcolor\012bcolor'), |
|
760 |
('bulletFontName', 'bfont\012bulletfontname'), |
|
761 |
('bulletFontSize', 'bfontsize\012bulletfontsize'), |
|
762 |
('bulletIndent', 'bindent\012bulletindent'), |
|
763 |
('firstLineIndent', 'findent\012firstlineindent'), |
|
764 |
('fontName', 'face\012fontname\012font'), |
|
765 |
('fontSize', 'size\012fontsize'), |
|
766 |
('leading', 'leading'), |
|
767 |
('leftIndent', 'leftindent\012lindent'), |
|
768 |
('rightIndent', 'rightindent\012rindent'), |
|
769 |
('spaceAfter', 'spaceafter\012spacea'), |
|
770 |
('spaceBefore', 'spacebefore\012spaceb'), |
|
771 |
('textColor', 'fg\012textcolor\012color')] |
|
772 |
t = Table(2*[None], len(data)*[None], data) |
|
338 | 773 |
t.setStyle([ |
333 | 774 |
('VALIGN',(0,0),(-1,-1),'TOP'), |
775 |
('INNERGRID', (0,0), (-1,-1), 0.25, colors.black), |
|
776 |
('BOX', (0,0), (-1,-1), 0.25, colors.black), |
|
338 | 777 |
]) |
333 | 778 |
lst.append(t) |
350 | 779 |
t=apply(Table,([None, None], [None, None, None, None, None, None, None, None, None, None, None, None, None, None, None], [('Attribute', 'Synonyms'), ('alignment', 'align, alignment'), ('bulletColor', 'bulletcolor, bcolor'), ('bulletFontName', 'bfont, bulletfontname'), ('bulletFontSize', 'bfontsize, bulletfontsize'), ('bulletIndent', 'bindent, bulletindent'), ('firstLineIndent', 'findent, firstlineindent'), ('fontName', 'face, fontname, font'), ('fontSize', 'size, fontsize'), ('leading', 'leading'), ('leftIndent', 'leftindent, lindent'), ('rightIndent', 'rightindent, rindent'), ('spaceAfter', 'spaceafter, spacea'), ('spaceBefore', 'spacebefore, spaceb'), ('textColor', 'fg, textcolor, color')])) |
780 |
t.repeatRows = 1 |
|
781 |
t.setStyle([ |
|
782 |
('FONT',(0,0),(-1,1),'Times-Bold',10,12), |
|
783 |
('FONT',(0,1),(-1,-1),'Courier',8,8), |
|
784 |
('VALIGN',(0,0),(-1,-1),'MIDDLE'), |
|
785 |
('INNERGRID', (0,0), (-1,-1), 0.25, colors.black), |
|
786 |
('BOX', (0,0), (-1,-1), 0.25, colors.black), |
|
354 | 787 |
('BACKGROUND', (0, 0), (-1, 0), colors.green), |
788 |
('BACKGROUND', (0, 1), (-1, -1), colors.pink), |
|
789 |
('ALIGN', (0, 0), (-1, 0), 'CENTER'), |
|
790 |
('ALIGN', (0, 1), (0, -1), 'LEFT'), |
|
791 |
('ALIGN', (-1, 1), (-1, -1), 'RIGHT'), |
|
792 |
('FONT', (0, 0), (-1, 0), 'Times-Bold', 12), |
|
793 |
('ALIGN', (1, 1), (1, -1), 'CENTER'), |
|
350 | 794 |
]) |
795 |
lst.append(t) |
|
326 | 796 |
SimpleDocTemplate('testtables.pdf', showBoundary=1).build(lst) |
6 | 797 |
|
798 |
if __name__ == '__main__': |
|
326 | 799 |
test() |