如何将整个 table 与 Python Reportlab 库对齐?

How to align a entire table with the Python Reportlab Library?

使用 reportlab 3.1.44 我试图将 table 左对齐(页面上的整个 table,而不是单元格)。 这是我的代码:

from reportlab.platypus import SimpleDocTemplate
from reportlab.platypus.tables import Table, TableStyle 
from reportlab.lib import colors 
from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_RIGHT

doc = SimpleDocTemplate('sample2.pdf', showBoundary=1) 
t = Table(
    (('','North','South','East','West'), 
    ('Quarter 1',100,200,300,400), 
    ('Quarter 2',100,400,600,800), 
    ('Total',300,600,900,'1,200')),

    (72,36,36,36,36), 
    (24,16,16,18)
) 

t.setStyle( 
    TableStyle([ 
        ('HALIGN',(0,0),(-1,-1),'LEFT'),\
        ('GRID', (0,0), (-1,-1), 0.25, colors.red, None, (2,2,1)), 
        ('BOX', (0,0), (-1,-1), 0.25, colors.blue), 
    ]) 
)
t.alignment = TA_LEFT
story = [t] 
doc.build(story) 

它仍然保持居中对齐。有什么解决办法吗?

显然 TableStyle 方法不起作用。 这是我如何让它工作的:

t = Table((('','North','South','East','West'), 
('Quarter 1',100,200,300,400), 
('Quarter 2',100,400,600,800), 
('Total',300,600,900,'1,200')), 
(72,36,36,36,36), 
(24, 16,16,18) 
,hAlign='LEFT')