[]
        
首页
开发者学堂
文档
论坛
市场
生态机会
活动
在线咨询 立即试用
(Showing Draft Content)

GC.Spread.Formatter.GeneralFormatter

Class: GeneralFormatter

Spread.Formatter.GeneralFormatter

Table of contents

Constructors

Methods

Constructors

constructor

• new GeneralFormatter(format?, cultureName?)

表示具有指定格式模式和格式字符串的格式化程序。

Parameters

Name Type Description
format? string 格式字符串(可选)。
cultureName? string 区域性名称(可选)。

Methods

format

▸ format(obj, formattedData?): string

使用格式化数据对象将指定对象格式化为字符串。

example

// 此示例使用 format 方法。
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 要格式化的单元格数据对象。
formattedData? Object 包含格式化数据的对象(可选)。

Returns

string

格式化后的字符串。


formatString

▸ formatString(value?): string | GeneralFormatter

获取或设置此格式化程序的格式字符串。

example

// 此示例获取格式字符串。
var formatter = new GC.Spread.Formatter.GeneralFormatter("#,##0.00");
var result = formatter.formatString();
console.log(result); // '#,##0.00'

Parameters

Name Type Description
value? string 此格式化程序的格式字符串。

Returns

string | GeneralFormatter

若无值设置,返回此格式化程序的格式字符串;否则返回格式化程序实例。


parse

▸ parse(str): Object

解析指定的文本。

example

// 此示例使用 parse 方法。
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

解析后的对象。