SpreadJS Documentation
GC.Spread.Sheets.ConditionalFormatting Namespace / Condition type / treatNullValueAsZero Method
Whether to treat the null value in a cell as zero.
In This Topic
    treatNullValueAsZero Method
    In This Topic
    Gets or sets whether to treat the null value in a cell as zero.
    Syntax
    var instance = new GC.Spread.Sheets.ConditionalFormatting.Condition(conditionType, args);
    var returnValue; // Type: any
    returnValue = instance.treatNullValueAsZero(value);
    function treatNullValueAsZero( 
       value : boolean
    ) : any;

    Parameters

    value
    Whether to treat the null value in a cell as zero.

    Return Value

    If no value is set, returns whether to treat the null value in a cell as zero; otherwise, returns the condition.
    Example
    This example sets the treatNullValueAsZero method.
    var nCondition = new GC.Spread.Sheets.ConditionalFormatting.Condition(GC.Spread.Sheets.ConditionalFormatting.ConditionType.cellValueCondition);
    nCondition.compareType(GC.Spread.Sheets.ConditionalFormatting.GeneralComparisonOperators.equalsTo);
    nCondition.expected(0);
    //When the option is false, the validation fails and the red alert is displayed.
    //When the option is true, the blank cell is treated as zero and the validation is successful.
    nCondition.treatNullValueAsZero(false);
    var validator = new GC.Spread.Sheets.DataValidation.DefaultDataValidator(nCondition);
    validator.type(GC.Spread.Sheets.DataValidation.CriteriaType.custom);
    validator.ignoreBlank(false);
    activeSheet.getCell(0, 0, GC.Spread.Sheets.SheetArea.viewport).validator(validator);
    spread.options.highlightInvalidData = true;
    activeSheet.setValue(0, 0, null);
    See Also

    Reference

    Condition type