1

I am in my way of creating an invoices web app with django. I use reportlab to generate pdf invoices. I've done everything but the client wants to remove the grid from rows inside the table, I try to colorize them with white but I got this result in image

my reportlab invoice result

this is my code of table :

    def myTable(tabledata):
        colwidths = (60, 320, 60, 60)
        t = Table(tabledata, colwidths)
        t.hAlign = 'RIGHT'
        GRID_STYLE = TableStyle(
            [
                ('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
                ('BOX', (0, 0), (-1, -1), 0.25, colors.black),
                ('LINEABOVE', (0,1), (-1,-1), 0.25, colors.white),

            ]
        )
        t.setStyle(GRID_STYLE)
        return t
yoonghm
  • 4,198
  • 1
  • 32
  • 48

1 Answers1

0

One way is to use color.hexcolor() and use a transparent color. Transparent white would be:

colors.HexColor('#00FFFFFF') 

Here is what your code would look like with the internal grid set to transparent:

def myTable(tabledata):
    colwidths = (60, 320, 60, 60)
    t = Table(tabledata, colwidths)
    t.hAlign = 'RIGHT'
    GRID_STYLE = TableStyle(
        [
            ('INNERGRID', (0, 0), (-1, -1), 0.25, colors.HexColor('#00FFFFFF')),
            ('BOX', (0, 0), (-1, -1), 0.25, colors.black),
        ]
    )
    t.setStyle(GRID_STYLE)
    return t

if you want to keep the column dividers:

def myTable(tabledata):
    colwidths = (60, 320, 60, 60)
    t = Table(tabledata, colwidths)
    t.hAlign = 'RIGHT'
    GRID_STYLE = TableStyle(
        [
            ('INNERGRID', (0, 0), (-1, -1), 0.25, colors.HexColor('#00FFFFFF')),
            ('BOX', (0, 0), (-1, -1), 0.25, colors.black),
            ('LINEAFTER', (0,0), (-1,-1), 0.25, colors.black),

        ]
    )
    t.setStyle(GRID_STYLE)
    return t
Alex Court
  • 68
  • 7