Reputation: 986
I am trying to create a Invoice template using reportlab. For the line items in the invoice, I am using a Table. The first row of the table contains the headers and the subsequent rows will be the actual line items. What I basically want to achieve is that if the table contains only 1 line item (plus one row of header), the table should span the entire page.
How can that be done? I don't see any way of specifying the height of the rows individually.
Thanks in advance.
Upvotes: 9
Views: 16648
Reputation: 166
You can specify each row heights when creating a Table object :
rows = [["Header1", "Header2"], ["Data1", "Data2"]]
table = Table(rows, colWidths=(50*mm, 50*mm), rowHeights=(10*mm, 250*mm))
To control text alignment in table cells, you can use TableStyle.
Upvotes: 14
Reputation: 8068
You can achieve this using TableStyles
and SPAN
commands. You can read more about how this works starting on page 81 of the ReportLab user manual. This will let you have cells span as many rows and columns as you want.
You can also use TableStyles
to adjust things like the width and hight of each row and column, but from your description that doesn't sound like what you really wanted to do.
Upvotes: 2