How to cancel numberFormat exponent

Posted by: 122368177 on 13 April 2020, 3:43 am EST

  • Posted 13 April 2020, 3:43 am EST

    2.222222222222222e+26 how to format

    there is two mthod

    1. C.Spread.Common.CultureManager.getCultureInfo(),

      decimalSeparator = ‘,’,but not ‘exponent’ to set
    2. export default class StringFormat extends GC.Spread.Formatter.GeneralFormatter {

      constructor(format: string, cultureName: string) {

      super(format, cultureName)

      }

      format(obj: Record<string, any>, formattedData: Record<string, any>) {

      if (typeof obj === ‘number’) {

      console.log(obj, formattedData)

      return super.format(obj, formattedData)

      } else if (typeof obj === ‘string’) {

      if (isnumeric(obj)) {

      return super.format(obj, formattedData)

      }

      }

      return obj ? obj.toString() : ‘’

      }

      parse(str: string) {

      return super.parse(str)

      }

      }

      how to format …
  • Posted 13 April 2020, 9:50 pm EST

    Could you help me provide the better way,Thanks~!

    Now

    export default class StringFormat extends GC.Spread.Formatter.FormatterBase {

    constructor(format: string, cultureName: string) {

    super(format, cultureName)

    }

    format(obj: any, data: any) {

    if (obj.indexOf(‘=’) === 0) {

    return new GC.Spread.Formatter.FormatterBase(obj, data).format(obj)

    } else {

    return obj.toString()

    }

    }

    parse(str: string) {

    if (!str) {

    return ‘’

    }

    return str

    }

    }

    I have to handle the celltype as string

  • Posted 13 April 2020, 10:30 pm EST

    Could you help me provide the better way,Thanks~!

    Now

    export default class StringFormat extends GC.Spread.Formatter.FormatterBase {

    constructor(format: string, cultureName: string) {

    super(format, cultureName)

    }

    format(obj: any, data: any) {

    if (obj.indexOf(‘=’) === 0) {

    return new GC.Spread.Formatter.FormatterBase(obj, data).format(obj)

    } else {

    return obj.toString()

    }

    }

    parse(str: string) {

    if (!str) {

    return ‘’

    }

    return str

    }

    }

    I have to handle the celltype as string

  • Posted 14 April 2020, 10:20 am EST

    Hi,

    This is the default behavior, when no formatter is specified, SpreadJS applies the general formatter which formats number values info scientific notification if col width is not enough to display the whole number. This behavior is the same as in MS Excel.

    Just like MS excel, SpreadJS also supports number formatter, if you need to display the number as text then you may set the formatter for the as “@”. Please refer to the following code snippet:

    sheet.setFormatter(row, col, "@");
    

    You may also refer to the following sample demonstrating the same: https://codesandbox.io/s/spread-js-starter-7bmnl?file=/src/index.js

    You may refer to the following doc for more info about the number formats: https://support.office.com/en-us/article/number-format-codes-5026bbd6-04bc-48cd-bf33-80f18b4eae68

    Regards

    Sharad

Need extra support?

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

Learn More

Forum Channels