Search code examples
pythonreportlab

Is it possible to make a table with only horizontal borders in reportlab?


Good day,

I have an array/list of the following design: data = [['colour', 'apple', 'pear', 'peach'], ['RED', 1, 2, 5], ['YELLOW', 6, 7, 9]]. I have seen many tutorials explaining how to add the inner grid and the box. But I would like to have somewhat close to such:

enter image description here

Do you know how to add only horizontal borders?


Solution

  • You should check out LineAbove and LineBelow in TableStyle page 77

    LIST_STYLE = TableStyle([('LINEABOVE', (0,0), (-1,0), 2, colors.green),
        ('LINEABOVE', (0,1), (-1,-1), 0.25, colors.black),
        ('LINEBELOW', (0,-1), (-1,-1), 2, colors.green)])