所以,一段時間以來,我一直在努力與這一個。我知道有很多類似的問題和很好的答案,而且我已經嘗試了這些答案,但是我所用的代碼基本上反映了給出的答案。VALUE在reportlab TableStyle顯然沒有效果
我正在編寫代碼來自動生成工作表的匹配練習。所有這些信息應該放在一個表格中。文本應該全部對齊到單元格的頂部。
這是我現在有:
from reportlab.lib.pagesizes import A4
from reportlab.platypus import SimpleDocTemplate, Paragraph, Table, TableStyle
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib.units import cm
document = []
doc = SimpleDocTemplate('example.pdf', pagesize=A4, rightMargin=72, leftMargin=72, topMargin=72)
styles = getSampleStyleSheet()
definitions = []
i, a = 1, 65
table = []
for x in range(1, 10):
line = []
line.append(Paragraph(str(i), styles['BodyText']))
line.append(Paragraph('Vocabulary', styles['BodyText']))
line.append(Paragraph(chr(a), styles['BodyText']))
line.append(Paragraph('Often a multi-line definition of the vocabulary. But then, sometimes something short and sweet.', styles['BodyText']))
table.append(line)
i += 1
a += 1
t = Table(table, colWidths=(1*cm, 4*cm, 1*cm, None))
t.setStyle(TableStyle([
('VALIGN', (1, 1), (-1, -1), 'TOP')
]))
document.append(t)
doc.build(document)
我是什麼俯瞰?
愛你的個人資料中的故事,我希望我的老師回到高中時會有同樣的態度! – B8vrede
謝謝!我不得不回去再讀一遍,但仍然如此。我不會說謊:今天它給了我幾根灰頭髮。 –