Cells format should be sting type, it should not be autoformat based on input

Posted by: ashok.purty on 11 March 2020, 8:02 am EST

    • Post Options:
    • Link

    Posted 11 March 2020, 8:02 am EST

    Hi,

    As per my requirement, sheadsheet cells should always string type. user can input datetime,value,currency anything but cells format should not autoformat.

    i) when i input some string date with specify format, then it get autoformat.

    Also do you have any library which can be use for data validation.

    ii) For decimal value, it get auto format to the exponential values for long values.

    Could you please help with some code samples.

  • Posted 11 March 2020, 11:27 am EST

  • Posted 12 March 2020, 1:16 am EST

    Hi Ashok,

    For formatting all the cells as string, we could simply set default formatter as the string for the sheet. Please refer to the following code snippet and the sample demonstrating the same:

    var defaultstyle = new GC.Spread.Sheets.Style();
    defaultstyle.formatter = "@";
    spread.getActiveSheet().setDefaultStyle(defaultstyle);
    

    https://codesandbox.io/s/spread-js-starter-rkht4

    Regards

    Sharad

  • Posted 12 March 2020, 5:12 am EST

    Thanks for quick response.

    Its working with my solution :slight_smile:

    Can you suggest some js library for date validation like format, valid date and the data range can be used with spreadsheet + angular 7 ?

  • Posted 13 March 2020, 7:49 am EST

    You could use the SJS formatter API to format and parse dates too. Please refer to the following code snippet:

    let dateFormat = "yyyy-MM-dd";
    let formatter = new GC.Spread.Formatter.GeneralFormatter(dateFormat);
    
    // format a date
    let date = new Date();
    let formattedDate = formatter.format(date);
    
    // parse date/ check for valid date
    let dateString = "2020-03-13";
    let parsedDate = formatter.parse(dateString);
    if(parsedDate instaceof Date){
        // date is valid, do something
    } else {
        // invalid date string
    }
    
  • Posted 14 March 2020, 4:05 am EST

    Thanks :slight_smile:

    I hope i it will fulfill my requirement

Need extra support?

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

Learn More

Forum Channels