[]
        
(Showing Draft Content)

Allow Invalid Formulas

SpreadJS supports marking cells in which the cell value is an invalid formula string. The InvalidFormula cell state can apply a style to a cell with a string value that matches the invalid formula.

allow-invalid-formula-pic.png


The CellStatesType enumeration provides the invalidFormula option to indicate that the cell value is an invalid formula string. You can also show whether the sheet allows an input invalid formula string. For this purpose, the GC.Spread.Sheets.IWorkbookOptions interface provides the allowInvalidFormula option. With this option, the user can input invalid formula in the editor directly, and the worksheet will keep it as a string. The default value for this option is false.


The code implementation below depicts setting an invalid formula state for a cell value:

spread.options.allowInvalidFormula = true;
var style = new GC.Spread.Sheets.Style();
var wholeRange = new GC.Spread.Sheets.Range(0, 0, sheet.getRowCount(), sheet.getColumnCount());
var borderTop = new GC.Spread.Sheets.LineBorder('red', GC.Spread.Sheets.LineStyle.mediumDashed);
var borderBottom = new GC.Spread.Sheets.LineBorder('red', GC.Spread.Sheets.LineStyle.mediumDashed);
var borderLeft = new GC.Spread.Sheets.LineBorder('red', GC.Spread.Sheets.LineStyle.mediumDashed);
var borderRight = new GC.Spread.Sheets.LineBorder('red', GC.Spread.Sheets.LineStyle.mediumDashed);
style.borderTop = borderTop;
style.borderBottom = borderBottom;
style.borderLeft = borderLeft;
style.borderRight = borderRight;
sheet.cellStates.add(wholeRange, GC.Spread.Sheets.CellStatesType.invalidFormula, style, GC.Spread.Sheets.SheetArea.viewport);

If two or more states intersect, the last set style takes priority and will compose with the other style. The priority of cell states is as follows:

edit > hover > active > selected > invalid formula > dirty > invalid > readonly