You can't set fixed point num_format entries (i.e. num_format="0.000")
because this looks to Workbook._save_all_num_formats() like a format
index.
The following fix seems to work (beware whitespace cut-n-paste)
--- Workbook.py.DIST 2004-08-20 09:16:16.000000000 +1000
+++ Workbook.py 2005-02-15 13:44:36.073001000 +1100
@@ -477,7 +477,7 @@
# Check if num_format is an index to a built-in format.
# Also check for a string of zeros, which is a valid format string
# but would evaluate to zero.
- if not re.match(r"^0+\d", num_format):
+ if not re.match(r"^0+[\d\.]", num_format):
if re.match(r"^\d+", num_format):
continue
if num_formats.has_key(num_format):
Logged In: NO
Hello, Gregory
Are you sure? Could you send example where this behaviour is
not working?
It's working well:
nf = wb.add_format(num_format="0.000")
ws.write([0,0], 3, nf)
Result: 3,000
BR EvgenyBF
test program to show this bug
Logged In: YES
user_id=293157
yep i'm sure. test program attached, and I'll add 2 produced XLS files - one before
the bugfix, one after.
The one before shows "1.234568" and the Format->Cells shows "General". The
one after shows "1.2346" and Format->Cells shows "Number" with decimal
places = 4.
Logged In: YES
user_id=293157
[ps: sorry for the delay, only just got back to this]
Output showing the bug
Logged In: YES
user_id=952405
Ohhh... when I was writing answer, I found mistake: Your
version is incorrect (old)
if re.match(r"^\d+", num_format):
continue
It must be
if re.match(r"^\d+$", num_format):
continue
So, all natural numbers are matched as built-in format
number. Alexey Morozov fixed it on Aug 27 :)
Revision 1.29
Fri Aug 27 14:44:32 2004 UTC (10 months ago) by morozov
Branch: MAIN
typo fix in _store_all_num_formats (sync w/ S::WE
Please, get the last version from CVS.