I need to change text style in particular cells in Table object (ReportLab). As far as I understand, it could be done via TableStayle class, but I can't find samples.
my_table = Table(data, colWidths=column_widths, rowHeights = row_heghts)
my_colour_black = [0, 0, 0]
my_colour_ligt_gray = [0.8, 0.8, 0.8]
my_colour_gray = [0.5, 0.5, 0.5]
my_colour_dark_gray = [0.2, 0.2, 0.2]
my_colour_white = [1, 1, 1]
my_table.setStyle(TableStyle([
('ALIGN',(0,0),(-1,0),'CENTER'),
('VALIGN',(0,0),(-1,0),'MIDDLE'),
('TEXTCOLOR',(0,0),(-1,0), my_colour_black),
('BACKGROUND',(0,0),(-1,0),my_colour_ligt_gray),
('ALIGN',(0,1),(-1,-1),'RIGHT'),
('VALIGN',(0,1),(-1,-1),'MIDDLE'),
('TEXTCOLOR',(0,1),(-1,-1),my_colour_gray),
('INNERGRID', (0,0), (-1,-1), 0.5, my_colour_white),
]))
I tried to find an answer in original documentation and another public sources (Google), but didn't find it. There are "FONT, FONTNAME (or FACE), FONTSIZE (or SIZE)" mentioned in the original documentation, but no samples how to use it.
Finally, I have found an answer. The format is: ('FONTNAME', (0,0), (-1,-1), 'Arial'), ('FONTSIZE', (0,0), (-1,0), 10),
Full listing of TableStyle :
current_tab_style = TableStyle([
('FONTNAME', (0,0), (-1,-1), 'Arial'), # font
('FONTSIZE', (0,0), (-1,0), 12),
('FONTSIZE', (0,1), (-1,-1), 10),
('ALIGN',(0,0),(-1,0),'CENTER'),
('VALIGN',(0,0),(-1,0),'MIDDLE'),
('TEXTCOLOR',(0,0),(-1,0), my_colour_black),
('BACKGROUND',(0,0),(-1,0),my_colour_ligt_gray),
('ALIGN',(0,1),(-1,-1),'RIGHT'),
('VALIGN',(0,1),(-1,-1),'MIDDLE'),
('TEXTCOLOR',(0,1),(-1,-1),my_colour_gray),
('INNERGRID', (0,0), (-1,-1), 0.5, my_colour_white),
])