[]
        
(Showing Draft Content)

GC.Spread.Formatter.FormatterBase

Class: FormatterBase

Spread.Formatter.FormatterBase

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new FormatterBase(format, cultureName)

Represents a custom formatter with the specified format string.

Parameters

Name Type Description
format string The format.
cultureName string The culture name.

Properties

typeName

typeName: string

Represents the type name string used for supporting serialization.

Methods

format

format(obj): string

Formats the specified object as a string with a conditional color. This function should be overwritten.

example

//This example creates a custom formatter.
var customFormatterTest = {};
customFormatterTest.prototype = GC.Spread.Formatter.FormatterBase;
customFormatterTest.format = function (obj, data) {
    data.conditionalForeColor = "blue";
    return "My format result : " + obj.toString();
};
customFormatterTest.parse = function (str) {
    if (!str) {
        return "";
    }
    return str;
}
activeSheet.getCell(1, 0).formatter(customFormatterTest);
activeSheet.getCell(1, 0).value("Test");

Parameters

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

Returns

string

The formatted string.


fromJSON

fromJSON(settings): void

Loads the object state from the specified JSON string.

Parameters

Name Type Description
settings Object The custom formatter data from deserialization.

Returns

void


parse

parse(str): Object

Parses the specified text. This function should be overwritten.

example

//This example creates a custom formatter.
var customFormatterTest = {};
customFormatterTest.prototype = GC.Spread.Formatter.FormatterBase;
customFormatterTest.format = function (obj, conditionalForeColor) {
    conditionalForeColor.value = "blue";
    return "My format result : " + obj.toString();
};
customFormatterTest.parse = function (str) {
    if (!str) {
        return "";
    }
    return str;
}
activeSheet.getCell(1, 0).formatter(customFormatterTest);
activeSheet.getCell(1, 0).value("Test")

Parameters

Name Type
str string

Returns

Object

The parsed object.


toJSON

toJSON(): Object

Saves the object state to a JSON string.

Returns

Object

The custom formatter data.