Am .02.2016, 13:46 Uhr, schrieb <
peter....@gmail.com>:
> Hello,I am using openpyxl on a Windows Client with a german Office
> Version.
> When saving the workbook, float values are saved as text, because float
> format uses a Point to separate decimals.
Saved by openpyxl? Then they are saved as floats using "%f.16g" to be
precise.
> Importing and changing locales only has an Impact on the possibility to
> Format, as I understood it.
>
> Import locale
> locale.setlocale(locale.LC_ALL, 'deu_deu')
This is irrelevant. Whether pi appears as 3.14 or 3,14 in Excel is
entirely down to the number format applied. Excel defaults to using a
comma as the separator for floats in German.
> c = 0.1
> v = locale.format("%g", c)
>
> would correct the Format to 0,1 but also changes the type to a string,
> which openpyxl obviously tells Excel . The number is saved as text.
Er, yes. Don't do this.
> I then tries to set he cell format ,, but unfortunately that has no
> effect either.
> ws.cell('%s%s'%(col, row)).number_format = '0.00'
Don't create cell addresses yourself. Just use ws.cell(row=1, col=1) (for
A1)
> Saving c also Ends up with the number formatted as text
>
> Can you please tell me what I am not seeing?
That Excel's localisation is deliberately confusing?
Charlie
--
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Kronenstr. 27a
Düsseldorf
D- 40217
Tel:
+49-211-600-3657
Mobile:
+49-178-782-6226