NumberCellType changes from 1.0.7 to 2.5.2008?

Posted by: de-guinsag on 8 September 2017, 1:03 pm EST

  • Posted 8 September 2017, 1:03 pm EST

    I'm currently using Spread for Windows Forms v 2.5.2008 which I upgraded to, from 1.0.7. I see that the number formatting in cells with NumberCellType format has changed from1.0.7 to 2.5.2008 when I changed my regional number settings from the US-English defaults (period as decimal separator and a space as thousand separator).

    When I update my regional settings and choose comma as the decimal separator and period as the thousand separator (keeping language as US), with 2.5.2008, the number "8000.96" is displayed as "800.096" and the number "8000,96" is displayed as "8.000,96". Both formatting make sense given my regional settings.

    The "problem" is that prior versions of the control expected numbers to be formatted in US-English for the control to display them properly based on the regional settings. So given the regional settings specified above, with version 1.0.7, "8000.96" would have correctly displayed as "8.000,96" not "800.096" as it does now with v 2.5.2008.

    Before I go ahead and remove my code (in several places) to convert numbers to US-English format before updating the Farpoint control (which is now unnecessary with v 2.5.2008), I'd appreciate if someone can confirm the number display implementation change.

    Also, please let me know if there is any way I can get the 2.5.2008 version of the control to display numbers as the previous versions did.

    Attached is a sample VS2005 project with Farpoint control v 2.5.2008 that shows the code I'm using to assign numbers to cells formatted as NumberCellType. The project shows the number being loaded from an XML string (which is what I do in my real application) or just assigned to the Value of the cell in a default sheet.

  • Replied 8 September 2017, 1:03 pm EST


    The behavior you are now seeing in the Spread control is the correct behavior. When you set the Value property of the cell, the data is not formatted and goes straight into the DataModel as you entered it (as a string in your case). Then, when the number is formatted, the Format method is called on the string and returning the values you are seeing based on the formatting you setup.

    To have the number formated in en-US settings in the DataModel and display correctly in the Spread cell no matter the regional settings, you would need to set the number into the cell as a double and not a string representation of the number.

        <SPAN class=kwd>double</SPAN> localizableAmount = 8000.96;
    FpSpread1_Sheet1.Cells[0, 1].Value = localizableAmount
  • Replied 8 September 2017, 1:03 pm EST

    Scott, thanks for the prompt reply.

    In my real application, I load data in the Farpoint control with an XML string. In the XML, all cells have a System.String type. I then change the CellType of the column with numbers on the fly, before displaying the control.

    Resetting the numbers as a double will not be a practical solution for me. I conclude that my only option now is to remove the code I use to format numbers in US-English format when generating the XML.

    Thanks again.

Need extra support?

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

Learn More

Forum Channels