write float to Excel with pyExcelerator write

John Machin sjmachin at lexicon.net
Mon Mar 3 07:14:54 EST 2008


On Mar 1, 5:59 pm, Cyril.Liu <terry6... at gmail.com> wrote:
> I use pyExcelerator to generat Excel files in my project. it works good
> before I found this bug:
> run this code:
>
> from pyExcelerator import *
> wb = Workbook()
> ws = wb.add_sheet("sheet")
> for i  in xrange(1):
>     ws.write(i,0, 10474224.6)
> wb.save(r'd:\error_float.xls')
>
> open d:\error_float.xls with M$ Excle you'll find the number in the cell is
> -263193.64 not 10474224.6
>
> why?

The author assumed unsigned integers instead of signed integers.

>>> 1047422460 - 2**30
-26319364

See the following, previously posted here:

http://mail.python.org/pipermail/python-list/2007-May/441633.html

Cheers,
John





More information about the Python-list mailing list