Formatting works with the style attributes. There’s also _argW and _argH lists which allow you to format the width of an entire row, or the height of an entire row.
for example this would affect the first row of table cells:
table._argH[0] = 5mm
this would affect the second row of table cells and so on:
table._argH[1] = 5mm
for the table elements you can also use a paragraph flowable inside a list so instead of {player_list}
, you can use [P]
from reportlab.lib.colors import *
from reportlab.lib.units import inch, mm, cm
P = Paragraph(''' The ReportLab Left Logo Image''',self.styles["BodyText"])
data= [['A', 'B', 'C', P0, 'D'],
['00', '01', '02', [P0], '04'],
['10', '11', '12', [P], '14'],
['20', '21', '22', '23', '24'],
['30', '31', '32', '33', '34']]
t=Table(data,style=[('GRID',(1,1),(-2,-2),1, green),
('BOX',(0,0),(1,-1),2,red),
('LINEABOVE',(1,2),(-2,2),1,blue),
('LINEBEFORE',(2,1),(2,-2),1,pink),
('BACKGROUND', (0, 0), (0, 1), pink),
('BACKGROUND', (1, 1), (1, 2), lavender),
('BACKGROUND', (2, 2), (2, 3), orange),
('BOX',(0,0),(-1,-1),2,black),
('GRID',(0,0),(-1,-1),0.5,black),
('VALIGN',(3,0),(3,0),'BOTTOM'),
('BACKGROUND',(3,0),(3,0),limegreen),
('BACKGROUND',(3,1),(3,1),khaki),
('ALIGN',(3,1),(3,1),'CENTER'),
('BACKGROUND',(3,2),(3,2),beige),
('ALIGN',(3,2),(3,2),'LEFT'),
])
t._argW[3]=1.5*inch
In terms of the table attributes, these images explain what these main attributes mean if you wanted to make your own custom style (without resorting to using the ‘BOX’ attribute).
Based on a 4x4 table: