【发布时间】:2016-09-23 22:24:51
【问题描述】:
我正在使用reportlab 创建一个表格,我想将下表中的单个单元格(向右)对齐:
我想将包含“职业”的单元格右对齐
这是我的代码:
studentProfileData = [
['Application Form No', ''],
['Name', userData['studentDetails']["firstName"] + " " +userData['studentDetails']["lastName"]],
['Course opted for', userData['courseDetails']["courseOptedFor"]],
['Specific Course Name', courseMapping["Name"]],
['Category', userData['studentDetails']['caste']],
['Religion', userData['studentDetails']['religion']],
['Fathers'+ "'" +'s Name', userData['studentDetails']['religion']],
['Occupation', userData['studentDetails']['fOccupation']],
['Phone No', ""],
['Term', ""]
]
colwidths = [3 * inch, 1.5 * inch, inch]
# Two rows with variable height
rowheights = [.5*inch] * len(studentProfileData)
studentProfile = Table(studentProfileData, colwidths, rowheights, hAlign='LEFT')
studentProfile.setStyle(TableStyle([
('ALIGN', (0, 0), (0, -1), "LEFT"),
('FONTSIZE', (0,0), (-1, -1), 13),
]))
parts = [ page1Head, studentProfile]
【问题讨论】:
-
你的意思是单元格而不是列?正如问题所说“我想将职业对齐”。
-
我只想对齐文本“职业”
标签: reportlab python django pdf-generation reportlab