[reportlab-users] Formatting decimals inside Table

Pasi Oja-Nisula pon at iki.fi
Fri Sep 7 02:40:45 EDT 2012


Hi,

I'm doing generic reports (recordsets from database) with Reportlab. By
looking at the data I can do left/right alignment based on datatype. I
just modify the tablestyle accordingly. But now I need to fix
decimal.Decimal fields. They look fine except the decimal point. I really
need an option to change this to comma instead of point. So if the data is
"1234.500" it needs to read "1234,500". Actually it would be nice to have
other formatting also, but for now this is the major stumbling point.

I googled and searched the archives and closest I found was
lib.formatters.DecimalFormatter, but it seems to be usable for charting
only. So far I have no ideas but to loop through the data and convert
Decimals to strings with something like str(d).replace('.', ',')

Am I missing something obvious or is this really the only option?

Thanks,

Pasi


More information about the reportlab-users mailing list