Set default number formatting

Posted by: nvitqrlfeqbusuabfa on 1 September 2021, 8:36 am EST

    • Post Options:
    • Link

    Posted 1 September 2021, 8:36 am EST

    Hello!

    Is there any way how to set default number format for every cell?

    I would like to display thousands separator in every number:

    In default value looks like this: 123456789

    However I would like to achieve this: 123,456,789

    I saw that there is setFormatter function:

    
    sheet.setFormatter(1, 1, '#,##0');
    
    

    Is there a way how to set this up globally for every cell. Even those that are not created yet?

    Thank you in advange.

    John

  • Posted 2 September 2021, 12:30 am EST

    Hi John,

    For this, you may use the setDefaultStyle method. Please refer to the following code snippet and let and let us know if you face any issues.

    
    
        /*Set the default styles.*/
        var defaultStyle = new GC.Spread.Sheets.Style();
        defaultStyle.formatter = "#,##0";
        sheet.setDefaultStyle(defaultStyle);
    
    

    API References:

    setDefaultStyle: https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Sheets.Worksheet~setDefaultStyle.html

    Regards,

    Avinash

  • Posted 2 September 2021, 3:31 am EST

    Thank you!

Need extra support?

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

Learn More

Forum Channels