SpreadJS formatter not working for number

Posted by: ngocnguyen09910060 on 18 April 2022, 3:11 am EST

    • Post Options:
    • Link

    Posted 18 April 2022, 3:11 am EST

    Hi teams,

    On my web application, i have a cell without any format.

    I’m facing an issue: I enter 111111111111111 but SpreadJS display 1.11111E+14

    I have researched and find a solution that using format “Text” (Text format cells are treated as text even when a number is in the cell. The cell is displayed exactly as entered.)

    I have implemented this solution:

    sheet.getRange(-1, 0, -1, 1).formatter("text");
    

    This is output:

    • “Enter: 1 => Output: A1899xA => Not good”

    • “Enter: 11111111 => Output: A32321xA => Not good”

    • “Enter: 111111111111111 => Output: 111111111111111 => OK”

    Please help me.

  • Posted 19 April 2022, 3:06 am EST

    Hi Ngọc,

    Entering 111111111111111 will display the value as 1.11111E+14. This is same behavior as compared to Excel and the General Formatter is applied.

    You should simply change the formatter to number formatter. For example, you can refer to the following sample that I have created for you: https://jscodemine.grapecity.com/share/-EpucknpuUGC92byH_8nhw/

    Please let us know if you require further assistance with your query? We will be happy to help you.

    Regards

    Ankit

  • Posted 19 April 2022, 5:16 am EST - Updated 3 October 2022, 9:19 am EST

    Hi ankit.kumar,

    I have checked on SpreadJS Designer and find a formatter that can help me resolve this problem. How can i implement this formatter in my source code ?

  • Posted 19 April 2022, 11:58 pm EST

    Hi,

    For this, please refer to the following code snippet and let me know if you face any issues.

    spread.getActiveSheet().setFormatter(0,0,"@")
    

    Regards,

    Avinash

  • Posted 20 April 2022, 2:20 am EST

    Hi avinash.pathak,

    I have applied your solution and it’s working.

    Thank you very much.

Need extra support?

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

Learn More

Forum Channels