[reportlab-users] How do I left-align my table?

Matthew Wilson matt at tplus1.com
Wed Nov 19 11:36:09 EST 2008


I have a small table and it is displayed in the center of the page.
How can I have it line up on the left margin like my paragraphs? I
understand how to mess with stuff inside the various table cells. I
don't care about that. Instead, I want to push the whole table box to
the left.


Here's the code I'm using:

def tfun(title, dt, data):

t = Table(data)

t.setStyle(TableStyle([
('GRID', (0, 0), (-1, -1), 0.5, colors.grey),
('BOX', (0, 0), (-1, -1), 2, colors.black),
]))

styles = getSampleStyleSheet()

def go():
doc = SimpleDocTemplate("foodservice.pdf")
style = styles["Normal"]

Story = []
Story.append(Paragraph(title, styles['Heading1']))
Story.append(Paragraph(dt.strftime('%A, %B %d, %Y'),
styles['Heading2']))

# This draws the table on to the page.
Story.append(t)

# This renders the doc.
doc.build(Story)

go()

if __name__ == '__main__':

employees = ('Matt Wilson', 'Matt Wilson', 'Matt Wilson')
data = [(emp, '6:00 AM') for emp in employees]

tfun('Food Service Schedule', datetime.now().date(),
data)


--
Matthew Wilson
matt at tplus1.com
http://tplus1.com


More information about the reportlab-users mailing list