简体   繁体   中英

Python: Reportlab. Table special line + RC index

I am new in Python. I have 2 huge problem (and no google search helped me), I use reportlab and my goal is a table with 3 colum and n rows. After the first row a vertical line (thicknass an the border 1 and in the midle 4). Problem, the Styl and the RC index: Part of the Problem: testtable=Table(data,style=[('LINEABOVE',(0,1),(2,1),1,colors.blue),
])
testtable=Table(data,style=[('LINEABOVE',(0,1),(2,1),1,colors.blue),
])
testtable=Table(data,style=[('LINEABOVE',(0,1),(2,1),1,colors.blue),
])
1. How can II draw the line over all 3 colums, in this example only 2 are working.
2. How can I define the line style.

Sorry if this is to basic, but I didn´t find a solution. Thanks for any help. Overlord

In the following example the comment is from an example from the reportlab mailing list and aims to explain the meaning of all line parameters. (I don't understand where join could apply.)

#!/usr/bin/env python3
# coding: utf-8

from reportlab.platypus import SimpleDocTemplate, Table, TableStyle
from reportlab.lib import colors

doc = SimpleDocTemplate('tab-styles.pdf')

# line commands are like
# op, start, stop, weight, colour, cap, dashes, join, linecount, linespacing

styles = TableStyle([
  ('GRID', (1,1), (-2,-2), 1, colors.red, 1, None, 1),
  ('BOX', (0,0), (-1,-1), 0.25, colors.green, None, (2,2,1)),
  ('LINEABOVE', (0,1), (2,1), 1 ,colors.blue, None, (5,3,1,3)),
  ('LINEABOVE', (0,2), (-1,2), 0.25 ,colors.blue, None, None, None, 4, 0.5),
  ('LINEABOVE', (0,3), (-1,3), 2 ,colors.blue, 1)
])

data = [['00', '01', '02', '03', '04'],
        ['10', '11', '12', '13', '14'],
        ['20', '21', '22', '23', '24'],
        ['30', '31', '32', '33', '34']]

t = Table(data , style=styles)

story = [t]
doc.build(story)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM