先了解表格怎么生成,这里插入介绍一下,下面示例代码:
data= [[ '00' , '01' , '02' , '03' , '04' ], [ '10' , '11' , '12' , '13' , '14' ], [ '20' , '21' , '22' , '23' , '24' ], [ '30' , '31' , '32' , '33' , '34' ]] stylelist= [('BACKGROUND', (0, 0), (-1, 0), colors.HexColor('#3094E9')),
('TEXTCOLOR', (0, 0), (-1, 0), 2, colors.white),
('LINEBEFORE', (1, 0), (1, -1), 1, colors.white),
('FONTSIZE', (2, 1), (-1, -1), 8)] table= Table(data04, style=stylelist) data就是表格要展示的内容。stylelist就是对表格的属性进行设置,具体参数不做讲解了。那么并列的表格怎么生成呢?看如下先定义第二个表格: data2= [[ '00' , '01' , '02' , '03' , '04' ], [ '10' , '11' , '12' , '13' , '14' ], [ '20' , '21' , '22' , '23' , '24' ], [ '30' , '31' , '32' , '33' , '34' ]] stylelist2 = [('BACKGROUND', (0, 0), (-1, 0), colors.HexColor('#3094E9')),
('TEXTCOLOR', (0, 0), (-1, 0), 2, colors.white),
('LINEBEFORE', (1, 0), (1, -1), 1, colors.white),
('FONTSIZE', (2, 1), (-1, -1), 8)] table2 = Table(data04, style=stylelist2) 然后将俩个表格作为data放进dataalllist。
dataall = [[table, table2]]
那么不难理解下面的写法:
tablenew = Table(dataall)
最后在将tablenew作为flowable加入进去最后进行build。