SpreadJS 13
GC.Spread.Formatter Namespace / FormatterBase type / format Method
The object with cell data to format.
The additonal format data.
The conditonal foreColor when format pattern contains color patter, such as [red]###.##
In This Topic
    format Method
    In This Topic
    Formats the specified object as a string with a conditional color. This function should be overwritten.
    Syntax
    var instance = new GC.Spread.Formatter.FormatterBase(format, cultureName);
    var value; // Type: string
    value = instance.format(obj, options, options.conditionalForeColor);
    function format( 
       obj : Object,
       (optional) options : Object,
       (optional) options.conditionalForeColor : string
    ) : string;

    Parameters

    obj
    The object with cell data to format.
    options
    The additonal format data.
    options.conditionalForeColor
    The conditonal foreColor when format pattern contains color patter, such as [red]###.##

    Return Value

    The formatted string.
    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");
    See Also