I've created a table using ReportLab. I would like to conditionally color the cells, depending on their contents (in my case, I want negative numbers to be red). To be clear, I have the conditional code working, I can't figure out how to add color. What I've tried:
- using the
<font color="...">
tag. Instead, the tags is included verbatim in the output. - wrapping each cell in
Paragraph(...)
(suggested in this answer). In this case, the cell text is linewrapped after each letter. - wrapping the table in
Paragraph(...)
. In this case, reportlab errors out (I believe the resulting error wasTypeError: split() missing required positional argument: 'availHeight'
) - I found
reportlab.platypus.tables.CellStyle
in the reportlab source code, but can't figure out make use of it. Google turns up nothing useful and it's not mentioned in the reportlab documentation. - I guess
TableStyle(...)
rules could be used, but the cells aren't in a predetermined position within the table (which is what all the examples assume).
Help appreciated!