[reportlab-users] Formatting decimals inside Table

Pasi Oja-Nisula pon at iki.fi
Fri Sep 7 04:28:34 EDT 2012

On Fri, Sep 7, 2012 at 10:52 AM, Andy Robinson <andy at reportlab.com> wrote:

> This is a deliberate design decision - it's easier to let you

> prepare the data, because otherwise we would need an infinite variety

> of formatting utilities - numeric formats, currency symbols, and all

> the special cases where someone doesn't want a number in that

> particular cell etc etc.

Excellent point. I hadn't really thought about the full picture.

> There is also a decimal alignment property for the table styles, which

> helps the English-language folks. tests/test_platypus_tables.py

> shows the use of this (example pasted below). However, it hunts

> within the string for a '.' character and aligns the string from that,

> so it won't do the same for a comma. I can take a look at whether we

> could make the 'pivot character' configurable in the table style if

> you wish.

I saw that property and it seems useful. Now I'm working with fixed decimals so
it's not directly applicable here. But it could also be useful maybe
aligning some
other kind of data. If the pivot character was configurable, I'd like
to be able to
use at least '-' there also. So why not use any available character.

I got the report report working by just having to change the order a
bit (build the
style first and then handle the data), since after converting the data
the additional
information (alignment etc.) that is based on datatype is lost.

Thanks for your help!


More information about the reportlab-users mailing list