GC.Spread.Sheets.ConditionalFormatting Namespace > Condition type : formula Method |
var instance = new GC.Spread.Sheets.ConditionalFormatting.Condition(conditionType, args); var returnValue; // Type: any returnValue = instance.formula(value);
function formula( value : string ) : any;
var textLengthCondition = new GC.Spread.Sheets.ConditionalFormatting.Condition(GC.Spread.Sheets.ConditionalFormatting.ConditionType.textLengthCondition); textLengthCondition.compareType(GC.Spread.Sheets.ConditionalFormatting.GeneralComparisonOperators.greaterThan); textLengthCondition.formula("$C$1"); // formula used to calculate a number. var validator = new GC.Spread.Sheets.DataValidation.DefaultDataValidator(textLengthCondition); validator.type(GC.Spread.Sheets.DataValidation.CriteriaType.custom); activeSheet.getCell(0, 0, GC.Spread.Sheets.SheetArea.viewport).validator(validator); spread.options.highlightInvalidData = true; activeSheet.setValue(0, 0, "abcf"); //Set value 3 to $C$1, after this code, the value in Cell(0,0) is valid. activeSheet.setValue(0, 2, 3); //Set value 5 to $C$1, after this code, the value in Cel(0,0) is invalid. // activeSheet.setValue(0, 2, 5);
var nCondition = new GC.Spread.Sheets.ConditionalFormatting.Condition(GC.Spread.Sheets.ConditionalFormatting.ConditionType.textCondition); nCondition.compareType(GC.Spread.Sheets.ConditionalFormatting.TextCompareType.contains); nCondition.formula("$C$1"); var validator = new GC.Spread.Sheets.DataValidation.DefaultDataValidator(nCondition); validator.type(GC.Spread.Sheets.DataValidation.CriteriaType.custom); activeSheet.getCell(0, 0, GC.Spread.Sheets.SheetArea.viewport).validator(validator); spread.options.highlightInvalidData = true; activeSheet.setValue(0, 0, "testing"); activeSheet.setValue(0, 2, "test");
var nCondition = new GC.Spread.Sheets.ConditionalFormatting.Condition(GC.Spread.Sheets.ConditionalFormatting.ConditionType.cellValueCondition); nCondition.compareType(GC.Spread.Sheets.ConditionalFormatting.GeneralComparisonOperators.greaterThan); nCondition.formula("$C$1"); var validator = new GC.Spread.Sheets.DataValidation.DefaultDataValidator(nCondition); validator.type(GC.Spread.Sheets.DataValidation.CriteriaType.custom); activeSheet.getCell(0, 0, GC.Spread.Sheets.SheetArea.viewport).validator(validator); spread.options.highlightInvalidData = true; activeSheet.setValue(0, 0, 5); activeSheet.setValue(0, 2, 4);
var nCondition = new GC.Spread.Sheets.ConditionalFormatting.Condition(GC.Spread.Sheets.ConditionalFormatting.ConditionType.dateCondition); nCondition.compareType(GC.Spread.Sheets.ConditionalFormatting.DateCompareType.before); nCondition.formula("$C$1"); var validator = new GC.Spread.Sheets.DataValidation.DefaultDataValidator(nCondition); validator.type(GC.Spread.Sheets.DataValidation.CriteriaType.custom); activeSheet.getCell(0, 0, GC.Spread.Sheets.SheetArea.viewport).validator(validator); spread.options.highlightInvalidData = true; activeSheet.setValue(0, 0, new Date(2012, 12, 12)); activeSheet.setValue(0, 2, new Date(2012, 11, 31));
var nCondition = new GC.Spread.Sheets.ConditionalFormatting.Condition(GC.Spread.Sheets.ConditionalFormatting.ConditionType.formulaCondition); nCondition.customValueType(GC.Spread.Sheets.ConditionalFormatting.CustomValueType.formula); nCondition.formula("A1>0"); var validator = new GC.Spread.Sheets.DataValidation.DefaultDataValidator(nCondition); validator.type(GC.Spread.Sheets.DataValidation.CriteriaType.custom); activeSheet.getCell(0, 0, GC.Spread.Sheets.SheetArea.viewport).validator(validator); spread.options.highlightInvalidData = true; activeSheet.setValue(0, 0, -4);
var nCondition = new GC.Spread.Sheets.ConditionalFormatting.Condition(GC.Spread.Sheets.ConditionalFormatting.ConditionType.numberCondition); nCondition.compareType(GC.Spread.Sheets.ConditionalFormatting.GeneralComparisonOperators.greaterThan); nCondition.formula("$C$1"); var validator = new GC.Spread.Sheets.DataValidation.DefaultDataValidator(nCondition); validator.type(GC.Spread.Sheets.DataValidation.CriteriaType.custom); activeSheet.getCell(0, 0, GC.Spread.Sheets.SheetArea.viewport).validator(validator); spread.options.highlightInvalidData = true; activeSheet.setValue(0, 0, 5); activeSheet.setValue(0, 2, 5);