[reportlab-users] Spreadsheet Table
Tomasz Świderski
contact at tomaszswiderski.com
Tue Feb 23 13:37:25 EST 2010
Andy Robinson wrote:
> On a separate topic, I bet people will immediately want to use this
> with various kinds of database query output. What do you think about
> adding formats to cell styles, so that a column could contain numeric
> data but still be specified to look like "$1,234.00" in the style?
>
>
It could be implemented as:
'FORMAT', (sc, sr), (ec, er), callable
where callable will take string as argument and return formated string.
Callable behavior will be up to users. For example:
def dollar_format(cell_value):
try:
return '$ %.2f' % float(cell_value)
except Exception:
return cell_value
or
def upper(cell_value):
return cell_value.upper()
It would complicate col widths calculation a bit but it's doable.
And this don't have to be limited to numeric data - for example format
callable which capitalize every word etc.
Tomasz Świderski
More information about the reportlab-users
mailing list