【发布时间】:2015-11-18 00:50:16
【问题描述】:
我正在将我的数据写入 pdf 表中,我的第一行有 4 列,第二行有 2 列,第三行有 4 列,依此类推
table.setStyle(TableStyle([
('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
('BOX', (0,0), (-1,-1), 0.25, colors.grey),
]))
这是我用来设置表格样式的代码,但我每行得到 4 列。我想根据我传递的列表的长度生成列,就像我的列表 li [[[1,2 ,3,4][1,2][1,2,3,4][1,2,3]] 在第一行中我需要 4 列,在第二行中需要 2 列等等。我如何使用 tablestyle 来实现它。
【问题讨论】:
-
@Andy Kubiak
code数据 = [[0, 1, 2, 3], [0, 1], [0, 1, 2, 3], [0, 1, 2] ] gridlines = [('GRID', (i, 0), (i, len(j)), colors.grey) for i, j in enumerate(data)] print gridlines style = TableStyle(gridlines) s = getSampleStyleSheet( ) s = s["BodyText"] t=Table(data) t.setStyle(style) 这是我的代码,我在 t.setstyle 中遇到异常