[]
Spread.Formatter.FormatterBase
• new FormatterBase(format
, cultureName
)
Represents a custom formatter with the specified format string.
Name | Type | Description |
---|---|---|
format |
string |
The format. |
cultureName |
string |
The culture name. |
• typeName: string
Represents the type name string used for supporting serialization.
▸ 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");
Name | Type | Description |
---|---|---|
obj |
Object |
The object with cell data to format. |
string
The formatted string.
▸ fromJSON(settings
): void
Loads the object state from the specified JSON string.
Name | Type | Description |
---|---|---|
settings |
Object |
The custom formatter data from deserialization. |
void
▸ 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")
Name | Type |
---|---|
str |
string |
Object
The parsed object.
▸ toJSON(): Object
Saves the object state to a JSON string.
Object
The custom formatter data.