1.背景
在reportlab中可以使用SimpleDocTemplate創(chuàng)建一個文檔,然后向里面添加內(nèi)容,但是直接添加內(nèi)容只能將值上下顯示,如果要將內(nèi)容左右顯示的話,可以使用reportlab中BalancedColumns,它可以將內(nèi)容分割成兩個或者更多大小相等的列。
2.使用
from reportlab.platypus.flowables import BalancedColumns
from reportlab.platypus.frames import ShowBoundaryValue
mytable = [[1,2,3,4],[5,6,7]]#按照這個格式填寫
img_activity=Image('./image/**.png')
F = [ mytable, img_activity]#在該列表中填寫需要分列展示的內(nèi)容
story.append(
Balanced(
F, #the flowables we are balancing
nCols = 2, #the number of columns
needed = 72,#the minimum space needed by the flowable
spacBefore = 0,
spaceAfter = 0,
showBoundary = None, #optional boundary showing
leftPadding=None, #these override the created frame
rightPadding=None, #paddings if specified else the
topPadding=None, #default frame paddings
bottomPadding=None, #are used
innerPadding=None, #the gap between frames if specified else
#use max(leftPadding,rightPadding)
name='', #for identification purposes when stuff goes awry
endSlack=0.1, #height disparity allowance ie 10% of available height
)
)
分列顯示的內(nèi)容,可以是表格、圖表、文字等
只是這樣將內(nèi)容分列,內(nèi)容上面的顯示仍然不是特別的靈活。
3.效果展示

image.png