我正在尝试制作一个包含表格的报告,并且该表格的数据是通过游览绘制的。
for valor in listDataRow:
pdf.set_font('Arial', '', 6)
pdf.cell(w = 15, h = 6, txt = str(valor[0]), border = 1, align = 'C', fill = 0)
pdf.set_font('Arial', '', 4)
pdf.cell(w = 55, h = 6, txt = str(valor[2]), border = 1, align = 'C', fill = 0)
pdf.set_font('Arial', '', 6)
pdf.cell(w = 48, h = 6, txt = str(valor[3]), border = 1, align = 'C', fill = 0)
pdf.set_font('Arial', '', 7)
pdf.cell(w = 8, h = 6, txt = str(valor[4]), border = 1, align = 'C', fill = 0)
pdf.set_font('Arial', '', 7)
pdf.cell(w = 8, h = 6, txt = str(valor[5]), border = 1, align = 'C', fill = 0)
pdf.set_font('Arial', '', 7)
pdf.cell(w = 8, h = 6, txt = str(valor[6]), border = 1, align = 'C', fill = 0)
pdf.set_font('Arial', '', 7)
pdf.cell(w = 8, h = 6, txt = str(valor[7]), border = 1, align = 'C', fill = 0)
pdf.set_font('Arial', '', 7)
pdf.cell(w = 8, h = 6, txt = str(valor[8]), border = 1, align = 'C', fill = 0)
pdf.set_font('Arial', '', 7)
pdf.cell(w = 8, h = 6, txt = str(valor[9]), border = 1, align = 'C', fill = 0)
pdf.set_font('Arial', '', 7)
pdf.cell(w = 8, h = 6, txt = str(valor[10]), border = 1, align = 'C', fill = 0)
pdf.set_font('Arial', '', 7)
pdf.cell(w = 14, h = 6, txt = str(valor[11]), border = 1, align = 'C', fill = 0)
pdf.set_font('Arial', '', 7)
pdf.cell(w = 27, h = 6, txt = str(valor[12]), border = 1, align = 'C', fill = 0)
pdf.set_font('Arial', '', 4)
if valor[1] == "None" or len(valor[1]) <= 71:
pdf.multi_cell(w = 57, h = 6, txt = str(valor[1]), border = 1, align = 'C', fill = False)
else:
pdf.multi_cell(w = 57, h = 3, txt = str(valor[1]), border = 1, align = 'C', fill = False)
这些数据在定义表头的位置后会自动容纳,问题在于multi_cell
必须始终在每条记录的末尾完成,以便它进行“换行”并继续绘制下一条记录。
进入该字段的字符串的大小非常可变,我尝试使用if valor[1] == "None" or len(valor[1]) <= 71:
您可以在代码中看到的条件 () 来控制它的高度。这不时起作用。
有时是这样的: 在此处输入图像描述
其他时候它会像这样出现: 在此处输入图像描述
如何调整我的报告的这一部分,使其高度正确,而不会被绳子的大小损坏?
感谢您的合作