SpreadJS 14
Formula Reference / Formula Overview / What is a Formula
In This Topic
    What is a Formula
    In This Topic

    Formulas can consist of values, operators, and functions. Data can be from other cells, a combination of data in another cell and hard-coded data (for example, A1 + 2), or simply hard-coded data (for example, SUM(4,5)). Formulas can perform mathematical operations, such as addition and multiplication, on values in other cells or they can compare values in other cells. Formulas can refer to cells in the same sheet by their absolute cell location or relative to the cell with the formula in it; they can refer to individual cells or a range of contiguous cells. If the values in the referenced cells change, then the value of the formula cell changes.

    Formulas can be made up of:

    Sample Formula

    Use the setFormula method in the Worksheet class for specifying the formula. Returning the value of the formula property provides a string containing the written expression of the formula, for example, SUM(A1:B1).

    In code the setting of a formula would look something like this in JavaScript (for illustration purposes only):

       sheet.getCell(2, 0).formula = "SUM(A1:A10)"

    and if added in the cell by the end user:


    In this documentation, where examples are shown, the formula appears as:



       SUM(3,4,5) gives the result 12

    to express that the result of the formula would display the value of 12 in the cell.