How to set the culture so Spread works on non-English Windows system

Posted by: Peter.Priestley on 21 March 2019, 5:28 pm EST

    • Post Options:
    • Link

    Posted 21 March 2019, 5:28 pm EST

    I’m using the Spread 12 and the new API to set a cell value and number format.

    Example.

    
    var wb = fpSpread1.AsWorkbook();
    var range = wb.ActiveSheet.Cells[1,1];
    range.Value = 1694.5452;
    range.NumberFormat = "0.000";
    
    

    On an English(US) system the cell is rendered like “1694.545”

    On a Windows system (e.g. Indonesia locale) where the regional setting specify the decimal point is a comma (,) and the thousands separator is a period (.) the cell is rendered like “1.695”.

    This kind of makes sense if the NumberFormat is interpreted using Indonesia locale (i.e. the period in 0.000 becomes a thousands separator rather than the decimal separator).

    So, I tried setting the Number Format using the local abstraction of the format string, i.e. “0,000” hoping the comma would act as the decimal point. Unfortunately, the cell is still rendered like “1.695” (rather than the desired “1695.545”).

    Two questions.

    1. Are NumberFormats meant to be localized, or should they always be written in English US? (I’m sure when using the old-API GeneralCellType.FormatString you just used English US in the FormatString and the output would be rendered according to the system settings.)

    2. How do I set the locale/culture/regional settings when using the new IWorkbook API?

  • Posted 21 March 2019, 6:09 pm EST

    One typo, in 3rd last paragraph, the desired value from my Indonesia system would be “1694,545”.

  • Posted 25 March 2019, 8:42 pm EST

    Hi,

    The regional formats in new API should work in the same way as old APIs work.

    We’ve asked the developers to look into this issue [Internal Tracking ID: 271000].

    We’ll update this thread as soon as we receive an update from them.

    Regards,

    Jitender

  • Posted 9 April 2019, 11:56 am EST

    Hi,

    Any news from the developers?

    I’d be particularly interested in a work around. I’m wondering if it is possible to write a custom formatter for the cells, at least to handle the non-english regional settings (and defer to the default formatter otherwise).

    Thanks,

    Peter P.

  • Posted 9 April 2019, 6:29 pm EST

    Hello,

    Your issue has been fixed by our developers and it will out in next release which is expected in the month of May’19.

    Unfortunately, we don’t have any workaround for the same.

    Thanks,

    Reeva

  • Posted 10 April 2019, 11:33 am EST

    Thanks Reeva, that is good news.

  • Posted 14 May 2019, 7:56 pm EST

    Hi Peter,

    The behavior of the new API is by-design. In the new API, the NumberFormat is interpreted according to the locale of the end-user. This change has been made to make Spread 12 consistent with Excel’s behavior.

    If you want to use the old behavior, then you should use GeneralCellType’s Format.

    Regards,

    Jitender

  • Posted 19 May 2019, 1:57 pm EST

    Hi Jitender,

    Well, I’m happy to have a ruling that NumberFormat should use the locale of the end-user. But that doesn’t work either, as per my example above (or is that the bit that Reeva said would be fixed in the May service pack?).

    Thanks,

    Peter P.

  • Posted 19 May 2019, 3:20 pm EST

    Hi Peter,

    Yes, that is fixed in SP1 build. In the latest build the value displayed (when using your code with NumberFormat = “0,000”) is 1694,545.

    Regards,

    Jitender

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels