Skip to content

Spreadsheet

Last updated 19 Nov 2026

NbSpreadsheet is an editable grid of cells for data people key in: dense rows, a sticky header, row numbers or labels in a gutter, keyboard entry like a desktop spreadsheet, range selection, clipboard, and undo. The app owns the data: the sheet renders it, captures input and emits the changes.

In sheet mode, a cell whose text starts with = is a formula. The cell keeps the formula and shows what it works out to, and the sheet works it out again whenever a cell it reads changes. The engine is the library's own, with no dependencies, and it is also published on its own as @nubisco/ui/formula.

Writing a formula ​

Type = in a cell, or in the formula bar above the grid, and then the formula. The formula bar shows the active cell's reference and its contents, a formula as written rather than its result.

  • References name a cell, B3, or a range, B2:B9. A whole column is C:C and a whole row is 3:3, both as far as the sheet's data reaches.
  • $ fixes a part of a reference: $A$1 stays put when the formula is filled or pasted elsewhere, $A1 keeps its column and A$1 its row. Without $, a reference moves with the formula.
  • Point instead of typing: while a formula waits for an operand, after =, a bracket, an operator or a separator, a click on a cell writes its reference, and a drag writes a range. In a cell opened by typing, the arrow keys do the same, and Shift with them makes a range.
  • Functions are offered as their name is typed. ↑ and ↓ move through the list, and Tab or Enter writes the function and its opening bracket. Inside the brackets, the function's arguments show under the field, the current one in bold.

While a formula is being edited, each reference has a colour, the same in the text and in a box on the grid around the cells it names.

Operators ​

OperatorMeaningExample
+ - * /Arithmetic=B2*C2
^Power=2^10
%Percent, after a number=B2*15%
&Joins text=A2&" (draft)"
= <> < > <= >=Comparisons, TRUE or FALSE=B2>=100
:A range=SUM(B2:B9)

Comparisons ignore the case of text, as a desktop spreadsheet's do. An empty cell is 0 in arithmetic and empty text when joined.

Dates and times ​

A date is a number: the days since 30 December 1899, with the time of day as the fraction, so 19 November 2026 is 46345 and noon that day is 46345.5. Dates subtract to a number of days and add days the same way: =B2-A2 is the days between two dates and =A2+30 the date a month on. A date typed into a cell, as 2026-11-19 or in the locale's short form, is stored as its number and given a date format, and a formula such as =TODAY() or =DATE(2026,11,19) shows as a date until its cell has a format of its own. Text such as "2026-11-19" reads as a date wherever a date is expected.

TODAY() and NOW() read the clock when the sheet works its formulas out, which is whenever a cell changes.

Arrays ​

A formula can hold a small table of constants in braces: {1,2,3} is a row, {1;2;3} a column, and {1,2;3,4} two rows of two. Any function that takes a range takes an array: =SUM({1,2,3}), =INDEX({"Low","Mid","High"},2), =VLOOKUP(B2,{0,"F";50,"C";70,"B";90,"A"},2). A cell shows one value, so a formula that ends in an array of more than one value is #VALUE!.

Your locale's syntax ​

A formula is typed and shown in the sheet's locale. Where the decimal separator is a comma, as in pt-PT or de-DE, arguments are separated with semicolons and decimals take the comma: =ROUND(B2*1,23;2). Inside an array the columns are then separated with a backslash and the rows with a semicolon, {1,5\2,5;3\4}. The cell stores the formula in one canonical form, =ROUND(B2*1.23,2), so the same cells read the same in every locale. Function names are always in English.

Errors ​

A formula that cannot be worked out shows an error code in the danger colour, and the cell's tooltip says why.

ErrorMeans
#DIV/0!A division by zero
#VALUE!A value of the wrong kind, such as text in arithmetic
#REF!A reference that leaves the sheet, or a circular reference
#NAME?A function the engine does not know
#N/AA lookup found nothing, or a function had the wrong number of values
#NUM!A number out of range, such as the square root of a negative
#ERROR!The formula itself does not parse

A cell that reads a cell with an error shows that error too, so the first one in a chain is the one to fix.

Filling, copying and pasting ​

The fill handle, Ctrl+D and Ctrl+R copy a formula and move its references with it: =B2*C2 filled down becomes =B3*C3, =B4*C4 and so on, while the parts fixed with $ stay. Pasting a formula copied from the same sheet moves it the same way, by the distance between the copy and the paste. A cut and paste moves the formula unchanged, as a desktop spreadsheet does.

Turning formulas off ​

A sheet whose text may start with = without being a formula sets :formulas="false". The cells then show their text as it is, and the formula bar is hidden unless formula-bar asks for it.

The engine on its own ​

@nubisco/ui/formula works out formulas without a sheet on the page, for a server, a worker or a test. It reads the same cells as sheet mode.

ts
import { createFormulaSheet, isFormulaError } from '@nubisco/ui/formula'

const sheet = createFormulaSheet()
const values = sheet.compute({ A1: 120, A2: 80, A3: '=SUM(A1:A2)' })
values.get('A3') // 200

const result = values.get('B1')
if (isFormulaError(result)) console.warn(result.error, result.message)

compute returns the result of every formula cell, keyed by reference, and keeps each formula's parse for the next call, so a change re-reads only the formulas whose text changed. It also exports the tokenizer, shiftFormula for moving references, toCanonical and toLocalized for the locale syntax, and FORMULA_FUNCTIONS, the list this page's reference is built from.

Functions ​

Math

FunctionSyntaxDescription
ABSABS(value)Returns a number without its sign.
CEILINGCEILING(value, [significance])Rounds a number up to the nearest multiple of a significance, 1 when left out.
EXPEXP(value)Returns e raised to a power.
FLOORFLOOR(value, [significance])Rounds a number down to the nearest multiple of a significance, 1 when left out.
INTINT(value)Rounds a number down to the nearest integer.
LNLN(value)Returns the natural logarithm of a number.
LOGLOG(value, [base])Returns the logarithm of a number in a base, 10 when left out.
LOG10LOG10(value)Returns the base 10 logarithm of a number.
MODMOD(dividend, divisor)Returns the remainder of a division, with the sign of the divisor.
PIPI()Returns the number pi.
POWERPOWER(base, exponent)Raises a number to a power.
PRODUCTPRODUCT(value1, [value2, ...])Multiplies numbers and the numbers in ranges.
ROUNDROUND(value, [digits])Rounds a number to a number of digits, halves away from zero.
ROUNDDOWNROUNDDOWN(value, [digits])Rounds a number toward zero to a number of digits.
ROUNDUPROUNDUP(value, [digits])Rounds a number away from zero to a number of digits.
SIGNSIGN(value)Returns 1 for a positive number, -1 for a negative one and 0 for zero.
SQRTSQRT(value)Returns the square root of a number.
SUMSUM(value1, [value2, ...])Adds numbers and the numbers in ranges.
SUMIFSUMIF(range, criterion, [sum_range])Adds the cells that meet a criterion.
SUMIFSSUMIFS(sum_range, criteria_range1, criterion1, [criteria_range2, criterion2, ...])Adds the cells that meet every criterion.
SUMPRODUCTSUMPRODUCT(array1, [array2, ...])Multiplies matching cells of ranges of the same size and adds the products.
TRUNCTRUNC(value, [digits])Cuts a number to a number of digits without rounding.

Statistical

FunctionSyntaxDescription
AVERAGEAVERAGE(value1, [value2, ...])Returns the arithmetic mean of numbers and the numbers in ranges.
AVERAGEIFAVERAGEIF(range, criterion, [average_range])Returns the mean of the cells that meet a criterion.
AVERAGEIFSAVERAGEIFS(average_range, criteria_range1, criterion1, [criteria_range2, criterion2, ...])Returns the mean of the cells that meet every criterion.
COUNTCOUNT(value1, [value2, ...])Counts the numbers among the values and in ranges.
COUNTACOUNTA(value1, [value2, ...])Counts the values and the cells in ranges that are not empty.
COUNTBLANKCOUNTBLANK(range)Counts the empty cells in a range, including cells with empty text.
COUNTIFCOUNTIF(range, criterion)Counts the cells in a range that meet a criterion.
COUNTIFSCOUNTIFS(criteria_range1, criterion1, [criteria_range2, criterion2, ...])Counts the positions where every criterion is met.
LARGELARGE(range, k)Returns the k-th largest number in a range.
MAXMAX(value1, [value2, ...])Returns the largest number, or 0 when there are none.
MEDIANMEDIAN(value1, [value2, ...])Returns the middle number, or the mean of the two middle numbers.
MINMIN(value1, [value2, ...])Returns the smallest number, or 0 when there are none.
SMALLSMALL(range, k)Returns the k-th smallest number in a range.
STDEVSTDEV(value1, [value2, ...])Returns the standard deviation of a sample.
VARVAR(value1, [value2, ...])Returns the variance of a sample.

Logical

FunctionSyntaxDescription
ANDAND(value1, [value2, ...])Returns TRUE when every value is true.
FALSEFALSE()Returns the logical value FALSE.
IFIF(condition, [value_if_true], [value_if_false])Returns one value when a condition is true and another when it is false.
IFERRORIFERROR(value, value_if_error)Returns a value, or a fallback when the value is any error.
IFNAIFNA(value, value_if_na)Returns a value, or a fallback when the value is #N/A.
IFSIFS(condition1, value1, [condition2, value2, ...])Returns the value paired with the first condition that is true.
NOTNOT(value)Returns the opposite of a logical value.
OROR(value1, [value2, ...])Returns TRUE when at least one value is true.
SWITCHSWITCH(expression, case1, value1, [case2, value2, ...], [default])Compares a value with a list of cases and returns the value of the first match.
TRUETRUE()Returns the logical value TRUE.
XORXOR(value1, [value2, ...])Returns TRUE when an odd number of values are true.

Text

FunctionSyntaxDescription
CONCATCONCAT(value1, [value2, ...])Joins values and the cells of ranges into one text.
CONCATENATECONCATENATE(value1, [value2, ...])Joins values into one text.
EXACTEXACT(text1, text2)Returns TRUE when two texts are the same, including case.
FINDFIND(search_for, text, [start])Returns the position of a text inside another, matching case.
LEFTLEFT(text, [count])Returns the first characters of a text, one when the count is left out.
LENLEN(text)Returns the number of characters in a text.
LOWERLOWER(text)Converts a text to lower case.
MIDMID(text, start, count)Returns characters from the middle of a text, counting from 1.
PROPERPROPER(text)Capitalises the first letter of each word and lowers the rest.
REPLACEREPLACE(text, start, count, new_text)Replaces a number of characters at a position, counting from 1.
REPTREPT(text, times)Repeats a text a number of times.
RIGHTRIGHT(text, [count])Returns the last characters of a text, one when the count is left out.
SEARCHSEARCH(search_for, text, [start])Returns the position of a text inside another, ignoring case and allowing wildcards.
SUBSTITUTESUBSTITUTE(text, old_text, new_text, [instance])Replaces occurrences of a text, or only the given occurrence.
TEXTTEXT(value, format)Formats a number or date as text with a format code such as "#,##0.00", "0%" or "yyyy-mm-dd".
TEXTJOINTEXTJOIN(delimiter, ignore_empty, value1, [value2, ...])Joins values with a delimiter, optionally leaving out empty ones.
TRIMTRIM(text)Removes spaces from both ends and collapses runs of spaces inside.
UPPERUPPER(text)Converts a text to upper case.
VALUEVALUE(text)Converts a text that looks like a number into the number.

Date and time

FunctionSyntaxDescription
DATEDATE(year, month, day)Returns the serial number of a date, rolling over months and days out of range.
DATEDIFDATEDIF(start_date, end_date, unit)Returns the whole years (Y), months (M) or days (D) between two dates, or the remainders MD, YM and YD.
DATEVALUEDATEVALUE(text)Converts an ISO date written as text into its serial number.
DAYDAY(date)Returns the day of the month of a date, 1 to 31.
DAYSDAYS(end_date, start_date)Returns the number of days between two dates.
EDATEEDATE(start_date, months)Returns the date a number of months before or after another.
EOMONTHEOMONTH(start_date, months)Returns the last day of the month a number of months before or after a date.
HOURHOUR(time)Returns the hour of a time, 0 to 23.
ISOWEEKNUMISOWEEKNUM(date)Returns the ISO 8601 week of the year, where weeks start on Monday.
MINUTEMINUTE(time)Returns the minute of a time, 0 to 59.
MONTHMONTH(date)Returns the month of a date, 1 to 12.
NETWORKDAYSNETWORKDAYS(start_date, end_date, [holidays])Counts the weekdays between two dates, inclusive, leaving out holidays.
NOWNOW()Returns the current date and time, recalculated on every change.
SECONDSECOND(time)Returns the second of a time, 0 to 59.
TIMETIME(hours, minutes, seconds)Returns a time of day as a fraction of a day.
TIMEVALUETIMEVALUE(text)Converts a time written as text into a fraction of a day.
TODAYTODAY()Returns today's date, recalculated on every change.
WEEKDAYWEEKDAY(date, [type])Returns the day of the week: type 1 counts Sunday as 1, type 2 Monday as 1, type 3 Monday as 0.
WEEKNUMWEEKNUM(date, [type])Returns the week of the year, with weeks starting on Sunday (type 1) or Monday (type 2).
WORKDAYWORKDAY(start_date, days, [holidays])Returns the date a number of weekdays after or before a date, skipping holidays.
YEARYEAR(date)Returns the year of a date.
YEARFRACYEARFRAC(start_date, end_date, [basis])Returns the fraction of a year between two dates, by a day count basis from 0 to 4.

Lookup and reference

FunctionSyntaxDescription
CHOOSECHOOSE(index, value1, [value2, ...])Returns the value at a position in a list of values, counting from 1.
COLUMNCOLUMN([reference])Returns the column number of a reference, or of the current cell.
COLUMNSCOLUMNS(range)Returns the number of columns in a range.
HLOOKUPHLOOKUP(key, table, row, [approximate])Finds a key in the first row of a table and returns the value in another row of that column.
INDEXINDEX(range, row, [column])Returns the value at a row and column of a range, counting from 1.
MATCHMATCH(key, range, [match_type])Returns the position of a key in a row or column: 1 for sorted ascending, 0 for exact, -1 for sorted descending.
ROWROW([reference])Returns the row number of a reference, or of the current cell.
ROWSROWS(range)Returns the number of rows in a range.
VLOOKUPVLOOKUP(key, table, column, [approximate])Finds a key in the first column of a table and returns the value in another column of that row.
XLOOKUPXLOOKUP(key, lookup_range, return_range, [if_not_found], [match_mode], [search_mode])Finds a key in a range and returns the matching item of another range, with a fallback when nothing matches.

Information

FunctionSyntaxDescription
ISBLANKISBLANK(value)Returns TRUE when a cell is empty.
ISERRORISERROR(value)Returns TRUE when a value is any error.
ISLOGICALISLOGICAL(value)Returns TRUE when a value is TRUE or FALSE.
ISNAISNA(value)Returns TRUE when a value is the #N/A error.
ISNUMBERISNUMBER(value)Returns TRUE when a value is a number.
ISTEXTISTEXT(value)Returns TRUE when a value is text.
NANA()Returns the #N/A error, for a value that is not available.