[]
        
(Showing Draft Content)

GC.Spread.Formatter.GeneralFormatter

Class: GeneralFormatter

Spread.Formatter.GeneralFormatter

Table of contents

Constructors

Methods

Constructors

constructor

new GeneralFormatter(format?, cultureName?)

Represents a formatter with the specified format mode and format string.

Parameters

Name Type
format? string
cultureName? string

Methods

format

format(obj, formattedData?): string

Formats the specified object as a string with a formatted data Object.

example

//This example uses the format method.
var formatter = new GC.Spread.Formatter.GeneralFormatter("#,##0.00");
var result = formatter.format(123456.789);
console.log(result); // '123,456.79'

Parameters

Name Type Description
obj Object The object with cell data to format.
formattedData? Object -

Returns

string

The formatted string.


formatString

formatString(value?): string | GeneralFormatter

Gets or sets the format string for this formatter.

example

//This example gets the format string.
var formatter = new GC.Spread.Formatter.GeneralFormatter("#,##0.00");
var result = formatter.formatString();
console.log(result); // '#,##0.00'

Parameters

Name Type Description
value? string The format string for this formatter.

Returns

string | GeneralFormatter

If no value is set, returns the formatter string for this formatter; otherwise, returns the formatter.


parse

parse(str): Object

Parses the specified text.

example

//This example uses the parse method.
var formatter = new GC.Spread.Formatter.GeneralFormatter("#,##0.00");
var result = formatter.parse("123,456.78");
console.log(result); // 123456.78

Parameters

Name Type
str string

Returns

Object

The parsed object.