What determines the vertical space in Reportlab tables?

(Don't have enough reputation to comment the other answer)

Regarding the last shortcut, simply "ROW_HEIGHT = 5 * mm" is working. No need to multiply the row height per the number of row in the table.

ROW_HEIGHT = 5 * mm
curr_table = Table(data, COL_WIDTHS, rowHeights=ROW_HEIGH )

Saves a bit of memory. :)


I don't believe there's a setting in TableStyle that allows you to change rowheight. That measurement is given when you're creating a new Table object:

Table(data, colwidths, rowheights)

Where colwidths and rowheights are lists of measurement values, like so:

from reportlab.lib.units import inch
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.platypus import Paragraph
from reportlab.platypus import Table
from reportlab.lib import colors

# Creates a table with 2 columns, variable width
colwidths = [2.5*inch, .8*inch]

# Two rows with variable height
rowheights = [.4*inch, .2*inch]

table_style = [
    ('GRID', (0, 1), (-1, -1), 1, colors.black),
    ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
    ('ALIGN', (1, 1), (1, -1), 'RIGHT')
]

style = getSampleStyleSheet()

title_paragraph = Paragraph(
    "<font size=13><b>My Title Here</b></font>",
    style["Normal"]
)
# Just filling in the first row
data = [[title_paragraph, 'Random text string']]

# Now we can create the table with our data, and column/row measurements
table = Table(data, colwidths, rowheights)

# Another way of setting table style, using the setStyle method.
table.setStyle(tbl_style)

report.append(table)

colwidths and rowheights can be changed to whatever measurement you need to fit the content. colwidths reads left to right, and rowheights reads top to bottom.

If you know that all of your table rows are going to be the same height, you can use this nice shortcut:

rowheights = [.2*inch] * len(data)

Which gives you a list like [.2*inch, .2*inch, ...] for every row in your data variable.