ReoGrid ReoGrid Web

Formula Engine

ReoGrid Web includes an Excel-compatible formula engine with 109 built-in functions across math, statistics, trigonometry, logical, text, date/time, lookup, info, conditional aggregation, and random categories. The engine features an AST parser, evaluator, and dependency graph for real-time recalculation.

The Lite edition supports arithmetic operators (+, -, *, /, ^, &), comparison operators, and cell references only. All 109 built-in functions require the Pro edition.

Live Demo

Basic Usage

Cell values starting with = are interpreted as formulas.

const ws = grid.worksheet

// Arithmetic operations
ws.cell('C1').value = '=A1+B1'
ws.cell('C2').value = '=A2*B2'

// Function calls
ws.cell('C3').value = '=SUM(A1:A10)'
ws.cell('C4').value = '=IF(A1>100,"High","Low")'
ws.cell('C5').value = '=VLOOKUP("Apple", A1:B100, 2, FALSE)'

Cell References

FormatDescriptionExample
Relative referenceRow and column indices shiftA1, B2
Absolute referenceFixed with $$A$1, A$1, $A1
Range referenceRange specified with colonA1:B10

Smart Formula Editor

While editing a formula (cell starting with =), the editor activates Excel-style reference editing:

  • Click another cell to insert that cell’s address at the caret. Drag to extend it into a range like A1:B5.
  • Click a different cell again to re-target the just-inserted reference (point mode). Typing or pressing arrow keys exits point mode.
  • Color-coded references. Each unique reference in the formula is colored from a shared palette; the grid draws a matching dashed rectangle around each referenced range using the same color. Highlight rectangles expand to enclose merged regions.

No API call is required — the editor activates automatically whenever a formula is being edited.


Built-in Functions

Full reference of all 109 built-in functions, grouped by category.

Math & Arithmetic (22)

FunctionSyntaxDescription
SUMSUM(value1, value2, ...)Sum
PRODUCTPRODUCT(value1, value2, ...)Product
AVERAGEAVERAGE(value1, value2, ...)Average
COUNTCOUNT(value1, value2, ...)Count of numeric cells
COUNTACOUNTA(value1, value2, ...)Count of non-empty cells
COUNTBLANKCOUNTBLANK(range)Count of blank cells
MAXMAX(value1, value2, ...)Maximum value
MINMIN(value1, value2, ...)Minimum value
ROUNDROUND(number, digits)Round to nearest
ROUNDUPROUNDUP(number, digits)Round away from zero
ROUNDDOWNROUNDDOWN(number, digits)Round toward zero
ABSABS(number)Absolute value
MODMOD(number, divisor)Remainder
INTINT(number)Truncate toward negative infinity
TRUNCTRUNC(number, [digits])Truncate toward zero
CEILINGCEILING(number, significance)Round up to multiple
FLOORFLOOR(number, significance)Round down to multiple
MROUNDMROUND(number, multiple)Round to nearest multiple
POWERPOWER(base, exponent)Exponentiation
SQRTSQRT(number)Square root
SIGNSIGN(number)Sign (1 / 0 / -1)
SUMPRODUCTSUMPRODUCT(array1, [array2, ...])Element-wise product sum

Statistics (4)

FunctionSyntaxDescription
MEDIANMEDIAN(value1, ...)Median
LARGELARGE(range, k)k-th largest value
SMALLSMALL(range, k)k-th smallest value
RANKRANK(value, range, [order])Rank (order=0 for descending)

Trigonometry & Logarithms (12)

FunctionSyntaxDescription
EXPEXP(number)e raised to the power
LNLN(number)Natural logarithm
LOGLOG(number, [base])Logarithm (base defaults to 10)
LOG10LOG10(number)Common logarithm
SINSIN(number)Sine (radians)
COSCOS(number)Cosine (radians)
TANTAN(number)Tangent (radians)
ASINASIN(number)Arcsine
ACOSACOS(number)Arccosine
ATANATAN(number)Arctangent
ATAN2ATAN2(x, y)Excel-compatible argument order
PIPI()Pi

Random (2)

FunctionSyntaxDescription
RANDRAND()Uniform random in [0, 1)
RANDBETWEENRANDBETWEEN(low, high)Uniform integer random

Note: RAND / RANDBETWEEN are currently not volatile — they do not auto-recalculate on every change. Re-enter the cell to refresh.

Logical (8)

FunctionSyntaxDescription
IFIF(condition, true_val, [false_val])Conditional branching
IFSIFS(cond1, value1, ...)Multi-branch (Excel 2019+)
IFERRORIFERROR(value, error_value)Catch any error
IFNAIFNA(value, na_value)Catch #N/A only
ANDAND(cond1, ...)Logical AND (short-circuit)
OROR(cond1, ...)Logical OR (short-circuit)
NOTNOT(condition)Logical negation
SWITCHSWITCH(expr, val1, result1, ..., [default])Match-by-value branching

Text (21)

FunctionSyntaxDescription
LENLEN(text)Character count
LEFTLEFT(text, [n])First n characters
RIGHTRIGHT(text, [n])Last n characters
MIDMID(text, start, length)Substring
UPPERUPPER(text)Convert to uppercase
LOWERLOWER(text)Convert to lowercase
PROPERPROPER(text)Capitalize first letter of each word
TRIMTRIM(text)Collapse whitespace
CONCATENATECONCATENATE(text1, ...)Concatenation (no ranges)
CONCATCONCAT(value1, ...)Concatenation (ranges expanded)
TEXTJOINTEXTJOIN(delimiter, ignore_empty, value1, ...)Delimiter-joined concatenation
TEXTTEXT(value, format)Format number as string
VALUEVALUE(text)Parse string to number
FINDFIND(search, text, [start])Case-sensitive position
SEARCHSEARCH(search, text, [start])Case-insensitive position; supports wildcards
EXACTEXACT(text1, text2)Case-sensitive equality
SUBSTITUTESUBSTITUTE(text, old, new, [occurrence])Replace by content
REPLACEREPLACE(text, start, count, new)Replace by position
REPTREPT(text, count)Repeat
CHARCHAR(code)Code point to character
CODECODE(text)Code point of first character

Date & Time (14)

FunctionSyntaxDescription
TODAYTODAY()Today’s serial (integer)
NOWNOW()Current date and time serial
DATEDATE(year, month, day)Build date serial
YEARYEAR(serial)Year
MONTHMONTH(serial)Month (1-12)
DAYDAY(serial)Day (1-31)
HOURHOUR(serial)Hour (0-23)
MINUTEMINUTE(serial)Minute (0-59)
SECONDSECOND(serial)Second (0-59)
WEEKDAYWEEKDAY(serial, [type])Day of week (types 1-3, 11-17)
EDATEEDATE(start, months)Add months (month-end clamped)
EOMONTHEOMONTH(start, months)End-of-month n months later
DAYSDAYS(end, start)Difference in days
DATEDIFDATEDIF(start, end, unit)Period (unit: D/M/Y/MD/YM/YD)

Lookup & Reference (11)

FunctionSyntaxDescription
VLOOKUPVLOOKUP(value, table, col_index, [approx])Vertical table lookup
HLOOKUPHLOOKUP(value, table, row_index, [approx])Horizontal table lookup
XLOOKUPXLOOKUP(value, lookup_range, return_range, [default], [match_mode], [search_mode])Modern lookup
INDEXINDEX(range, row, [column])Value by position
MATCHMATCH(value, range, [match_type])Position of value
XMATCHXMATCH(value, range, [match_mode], [search_mode])Modern MATCH
ROWROW([reference])Row number
COLUMNCOLUMN([reference])Column number
ROWSROWS(range)Number of rows in range
COLUMNSCOLUMNS(range)Number of columns in range
ADDRESSADDRESS(row, column, [abs], [a1], [sheet])Build A1/R1C1 address string

Limitation: Single-cell ROW(A5) is not currently supported (returns #VALUE!). Argument-less ROW() / COLUMN() and range arguments ROW(A1:A10) work.

Not yet implemented: INDIRECT and OFFSET require volatile-cell support in the dependency graph; planned for a future release.

Info & Error Checking (9)

FunctionSyntaxDescription
ISBLANKISBLANK(value)TRUE if blank
ISNUMBERISNUMBER(value)TRUE if numeric
ISTEXTISTEXT(value)TRUE if text
ISLOGICALISLOGICAL(value)TRUE if boolean
ISERRORISERROR(value)TRUE if any error (including #N/A)
ISERRISERR(value)TRUE if error other than #N/A
ISNAISNA(value)TRUE if #N/A
NANA()Returns #N/A
ERROR.TYPEERROR.TYPE(value)Error code number (1-8)

Conditional Aggregation — *IF / *IFS (6)

FunctionSyntaxDescription
SUMIFSUMIF(range, criteria, [sum_range])Single-criteria sum
COUNTIFCOUNTIF(range, criteria)Single-criteria count
AVERAGEIFAVERAGEIF(range, criteria, [average_range])Single-criteria average
SUMIFSSUMIFS(sum_range, range1, criteria1, ...)Multi-criteria sum
COUNTIFSCOUNTIFS(range1, criteria1, ...)Multi-criteria count
AVERAGEIFSAVERAGEIFS(average_range, range1, criteria1, ...)Multi-criteria average

Criteria syntax

SUMIF / COUNTIF / AVERAGEIF and their *IFS variants accept:

ExampleMeaning
5Value equals 5
"apple"Text equals apple (case-insensitive)
">5"Greater than 5
">=10"Greater than or equal to 10
"<>0"Not equal to 0
"a*"Text starts with a
"?at"Any single character + at

Automatic Dependency Tracking

Dependencies between formulas are tracked automatically. When a cell value changes, all formulas that reference that cell are automatically recalculated.

ws.cell('A1').value = '10'
ws.cell('B1').value = '20'
ws.cell('C1').value = '=A1+B1'  // -> 30

// Changing A1 automatically recalculates C1
ws.cell('A1').value = '50'      // C1 -> 70

You can rebuild formula dependencies after bulk data changes:

ws.rebuildFormulas()

Example: Invoice with Lookup

const ws = grid.worksheet

// Price table (A1:B4)
ws.cell('A1').value = 'Product'; ws.cell('B1').value = 'Unit Price'
ws.cell('A2').value = 'Widget';  ws.cell('B2').value = '500'
ws.cell('A3').value = 'Gadget';  ws.cell('B3').value = '1200'
ws.cell('A4').value = 'Sprocket'; ws.cell('B4').value = '350'

// Line items (D1:G4)
ws.cell('D1').value = 'Item'; ws.cell('E1').value = 'Qty'
ws.cell('F1').value = 'Price'; ws.cell('G1').value = 'Amount'

ws.cell('D2').value = 'Widget'
ws.cell('E2').value = '10'
ws.cell('F2').value = '=VLOOKUP(D2,$A$2:$B$4,2,FALSE)'  // -> 500
ws.cell('G2').value = '=E2*F2'                          // -> 5000

// Total
ws.cell('G5').value = '=SUM(G2:G4)'
ws.cell('G6').value = '=ROUND(G5*0.1,0)'  // 10% tax
ws.cell('G7').value = '=G5+G6'            // total

Edition Comparison

FeatureLite (Free)Pro (Paid)
Arithmetic & comparison operatorsYesYes
Cell & range referencesYesYes
Dependency graphYesYes
Smart formula editor (color-coded refs)YesYes
Built-in functions (109)Yes
Stay Updated

Be first to know — get updates as they ship

Get notified of new releases, features, and announcements.
No spam — just updates that matter.