A spreadsheet plugin for MulmoChat - a multi-modal voice chat application with OpenAI's GPT-4 Realtime API.
This plugin provides a full-featured spreadsheet component with:
- Excel-like cell editing with formula support
- Mathematical functions (SUM, AVERAGE, MIN, MAX, etc.)
- Text functions (CONCATENATE, LEFT, RIGHT, MID, etc.)
- Date functions (TODAY, NOW, DATE, YEAR, MONTH, DAY, etc.)
- Logical functions (IF, AND, OR, NOT, etc.)
- Lookup functions (VLOOKUP, HLOOKUP, INDEX, MATCH)
- Financial functions (PMT, PV, FV, NPV, IRR)
- Multi-sheet support
- Excel file export (.xlsx)
- Saving to the host's artifacts area, with cell edits written back
- UI in 8 languages, following the host's locale
- Cell formatting and styling
- A number with no format, or in General, shows as a standard-width Excel column shows it: at most 11 characters, or 6 digits in scientific form (
0.333333333,1.23457E+11). The stored value and the reply keep every digit, and copy carries the text the card shows
Note: This package uses SheetJS for Excel file export. SheetJS is not installed from npm, but directly from the official SheetJS CDN:
https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgzSee SheetJS Installation Guide for details.
yarn add @gui-chat-plugin/spreadsheet gui-chat-protocol
gui-chat-protocolis a peer dependency — install it alongside the plugin; the host application provides the runtime and this plugin only declares the compatible range.
The package runs on an ES2023 runtime: Node 22 or later, Chrome 110, Safari 16, Firefox 115 or later. It uses ES2023's array methods (
toSorted,toReversed) as they are, with no polyfill.
// In src/tools/index.ts
import SpreadsheetPlugin from "@gui-chat-plugin/spreadsheet/vue";
const pluginList = [
// ... other plugins
SpreadsheetPlugin,
];
// In src/main.ts
import "@gui-chat-plugin/spreadsheet/style.css";import { pluginCore, TOOL_NAME } from "@gui-chat-plugin/spreadsheet";The plugin works in two modes, chosen by what the host passes to execute:
- With
files.artifacts(the gui-chat-protocol runtime capability): the workbook is written toartifacts/spreadsheets/YYYY/MM/<id>.jsonanddata.sheetsholds that path. The View reads and saves it throughuseRuntime().dispatch, so cell edits land in the same file and the model can read them back from it. - Without it:
data.sheetsholds the workbook itself, and edits are reported throughupdateResultonly.
The View sends two dispatch calls:
kind |
other args | result |
|---|---|---|
loadSpreadsheet |
path |
{ data: { sheets, version } } |
saveSpreadsheet |
path, sheets, baseVersion? |
{ data: { sheets: path, version } }, or { data: { sheets, version, conflict: true } } |
path must be a .json file under artifacts/spreadsheets/.
version is the SHA-256 of the file's text. The View saves with the baseVersion of the sheets it shows, and the save is written only while the file still has that version. When an agent or another View wrote the file in between, nothing is written: the answer carries the file's current sheets and version with conflict: true, and the View asks the user to keep that version or save their edit over it. A save without baseVersion is written unconditionally, as before. Saves of one file through the plugin are serialized, so two Views cannot both pass the check; a write that bypasses the plugin can still land between a save's check and its write, because files.artifacts has no compare-and-write.
A host that routes the View's dispatch to the plugin's own execute (as MulmoTerminal does) needs nothing more: pluginCore.execute tells the two calls apart by kind. A host with its own dispatch route can call executeSpreadsheetDispatch(files.artifacts, args) after checking isSpreadsheetDispatchArgs(args).
The View must be rendered inside the host's PLUGIN_RUNTIME_KEY provider to load or save a saved workbook; it also takes the UI language from that runtime (en, ja, de, es, fr, ko, pt-BR, zh, falling back to English).
The download button writes the workbook as an .xlsx file whose cells keep their types:
- Values. A number is a number, TRUE and FALSE are booleans, and text is text, so a code typed as
007or"42"stays text. A date typed as text (2025-01-03,1/3/2025) is written as the date it calculates to, formattedyyyy-mm-dd; text the card keeps as text, such as a time (10:30), stays text. A cell's own number format (0.00%,$#,##0.00) is kept. - Formulas. A formula Excel reads as this engine does is written as a formula, with its answer cached, so Excel shows the answer before it recalculates. Excel's newer functions are written as Excel's own files spell them (
_xlfn.XLOOKUP,_xlfn._xlws.FILTER), andA1#as_xlfn.ANCHORARRAY(A1). Each formula is written as a dynamic-array formula over the range it spilled into (one cell when it did not spill), as Excel saves its own. A formula that shows a date gets the date format the card shows it in. - Formulas written as their answers. A formula Excel would read differently is written as the value it calculated: one calling a function Excel lacks (Google Sheets' SPLIT, QUERY, SPARKLINE and ARRAYFORMULA, the pandas-style CUMSUM and ROLLING, the statistical tests), a workbook function, LET, LAMBDA and the functions taking one (MAP, BYROW, GROUPBY and the rest), a defined name,
@, or a trim reference (A1:.A10). Excel would open these as#NAME?, so the file keeps what the card showed instead. - Errors.
#DIV/0!,#N/A,#VALUE!,#REF!,#NAME?,#NUM!and#NULL!are written as errors.#SPILL!,#CALC!and Sheets'#ERROR!are written as text, since the file format has no code for them. - Limits. Text longer than Excel's cell limit (32,767 characters) is cut there. Dates are numbered as in Excel, so a date and a formula's answer are written as calculated.
3.0.0 changes what a host receives, so it is a major release:
SpreadsheetToolData.sheetsisSpreadsheetSheet[] | string. Withfiles.artifactsthe tool returns the saved file's path instead of the workbook, so code that readsdata.sheetsas an array has to handle the path (or load it with theloadSpreadsheetdispatch).pluginCore.executealso acceptsSpreadsheetDispatchArgs.- The
gui-chat-protocolpeer is^2.3.0, and the package no longer bundles it: the host's copy is used. - Cells may hold a boolean
v, and stored workbooks may contain bare values,nullgaps and{}cells (StorableCell).
| Export | Description |
|---|---|
@gui-chat-plugin/spreadsheet |
Core (framework-agnostic) |
@gui-chat-plugin/spreadsheet/vue |
Vue implementation with UI components |
@gui-chat-plugin/spreadsheet/style.css |
Tailwind CSS styles |
A host whose own guidance lists the functions a formula may call can check that list against the engine: registeredFunctionsByCategory() (from ./core) returns each category's function names, sorted, as below, and isRegisteredFunction(name) tells whether a name is one of them, in any case.
ABS, ACOS, ACOSH, ACOT, ACOTH, AGGREGATE, ARABIC, ASIN, ASINH, ATAN, ATAN2, ATANH, BASE, CEILING, CEILING.MATH, CEILING.PRECISE, COMBIN, COMBINA, COS, COSH, COT, COTH, CSC, CSCH, DECIMAL, DEGREES, ECMA.CEILING, EVEN, EXP, FACT, FACTDOUBLE, FLOOR, FLOOR.MATH, FLOOR.PRECISE, GCD, INT, ISO.CEILING, LCM, LN, LOG, LOG10, MDETERM, MINVERSE, MMULT, MOD, MROUND, MULTINOMIAL, MUNIT, ODD, PERCENTOF, PERMUT, PI, POWER, PRODUCT, QUOTIENT, RADIANS, RAND, RANDARRAY, RANDBETWEEN, ROMAN, ROUND, ROUNDDOWN, ROUNDUP, SEC, SECH, SEQUENCE, SERIESSUM, SIGN, SIN, SINH, SQRT, SQRTPI, SUBTOTAL, SUMPRODUCT, SUMSQ, SUMX2MY2, SUMX2PY2, SUMXMY2, TAN, TANH, TRUNC
Angles are in radians (=SIN(RADIANS(30))). ATAN2(x, y) takes x first, as in Excel. ROUND, ROUNDUP, ROUNDDOWN, FLOOR, CEILING, POWER, SQRT, MOD, INT, TRUNC, EXP, LN, LOG and LOG10 read an argument as Excel does: an error is the answer, text that is a number is that number ("12.5", "50%") and text that is a date its serial ("2024-01-10", with no space around it), TRUE and FALSE are 1 and 0, a blank cell or an empty argument is 0, and any other text is #VALUE! (=ROUND("a",1)). REPLACE reads its start and count the same way. An argument that is a flag (NORM.DIST's cumulative, TEXTJOIN's ignore_empty, UNIQUE's by_col and exactly_once, SORT's by_col, TOCOL's and TOROW's scan_by_column, DAYS360's method, FIXED's no_commas, LINEST's, LOGEST's, TREND's and GROWTH's const and stats) reads as IF reads its condition: a number is TRUE unless 0, TRUE and FALSE written as text are as written, a blank is FALSE, and other text is #VALUE!.
SUBTOTAL runs function 1 AVERAGE, 2 COUNT, 3 COUNTA, 4 MAX, 5 MIN, 6 PRODUCT, 7 STDEV, 8 STDEVP, 9 SUM, 10 VAR or 11 VARP over its references and leaves out the cells that hold another SUBTOTAL, so a grand total over a table with subtotals counts each value once. 101–111 are the same functions; Excel uses them to leave hidden rows out, and no row is hidden here.
AGGREGATE runs one of nineteen functions: 1–13 over references as SUBTOTAL's (7 STDEV.S, 10 VAR.S, 12 MEDIAN, 13 MODE.SNGL among them), 14–19 over an array with k (LARGE, SMALL, PERCENTILE.INC, QUARTILE.INC, PERCENTILE.EXC, QUARTILE.EXC). Its options leave out nested SUBTOTAL and AGGREGATE cells (0–3) and error values (2, 3, 6, 7): =AGGREGATE(9,6,B2:B10) sums a column past its #N/As.
An aggregate such as SUM, COUNT, AVERAGE, MAX, MIN, PRODUCT, MEDIAN, the STDEV and VAR families, NPV, the values of SUMIF, SUMIFS, AVERAGEIF, AVERAGEIFS, MAXIFS and MINIFS, and the pairs of CORREL, SLOPE, SUMX2MY2 and the like skips text inside a reference or an array, numeric text included, as Excel does: =SUM({"100",100}) is 100, and a cell whose formula answers ="5" is not counted. Text written directly as an argument is read as its number (=SUM("100",1) is 101), except by NPV, which leaves out every value written directly that is not a number, as Microsoft documents; and a number typed into a cell is a number, whether it was written as 100 or "1,200". The A-variants (COUNTA, AVERAGEA, MAXA and the like) read text as Excel does. An IF, IFS, CHOOSE or SWITCH that one value decides is read as the argument it chooses, written in its place, and an IFERROR or IFNA as its value or its fallback: =SUM(CHOOSE(2,B1:B3,TRUE)) is 1, as =SUM(TRUE) is; AND, OR and XOR read them the same way. A LET is read as its calculation with its names written in: =SUM(LET(x,TRUE,x)) is 1.
A date written in quotes inside a formula is text, as in Excel: =LEN("2024-01-10") is 10, =ISTEXT("2024-01-10") is TRUE, and ="2024-01-10"=DATE(2024,1,10) is FALSE. Where a number is needed it reads as that date: ="2024-01-10"+1 is 45302, and =VALUE("2024-01-10") and =--"2024-01-10" are 45301. With a space around it, it does not (=" 2024-01-10 "+0 is #VALUE!), though DATEVALUE still reads it. To compare a cell with a date, write the date as DATE(2024,1,10).
Texts compare as Excel compares them. =, <, SORT, SORTBY, UNIQUE, GROUPBY, PIVOTBY, SWITCH, XLOOKUP and XMATCH, and a COUNTIF, SUMIF or D-function criteria without wildcards ignore case, width, hiragana against katakana, small kana against large, and compatibility forms: ="あ"="ア", ="ガ"="ガ", ="A"="a", ="①"="1", ="ß"="ss" and ="ij"="ij" are TRUE. Accents count (="ä"="a" is FALSE), the long-vowel mark and the iteration marks sort before every kana (="かー"<"かあ" is TRUE), kanji stay apart, and a control character, soft hyphen or zero-width space is ignored inside a text but counts at its end. MATCH, VLOOKUP and HLOOKUP, and every wildcard pattern, fold one character at a time instead: case, width, kana and one-character forms such as ① fold, but ß does not match ss and ガ does not match ガ there. A criteria's wildcard pattern reads a half-width kana and its voiced mark as one character. A numeric criteria ("2") matches text as written, so it skips ².
ARRAYTOTEXT, ASC, BAHTTEXT, CHAR, CLEAN, CODE, CONCAT, CONCATENATE, DBCS, DOLLAR, ENCODEURL, EXACT, FIND, FINDB, FIXED, JIS, JOIN, LEFT, LEFTB, LEN, LENB, LOWER, MID, MIDB, NUMBERVALUE, PHONETIC, PROPER, REGEXEXTRACT, REGEXMATCH, REGEXREPLACE, REGEXTEST, REPLACE, REPLACEB, REPT, RIGHT, RIGHTB, SEARCH, SEARCHB, SPLIT, SUBSTITUTE, TEXT, TEXTAFTER, TEXTBEFORE, TEXTJOIN, TEXTSPLIT, TRIM, UNICHAR, UNICODE, UPPER, USDOLLAR, VALUE, VALUETOTEXT
The B functions count bytes as Excel does with a double-byte language (Japanese) as the default: a character Shift_JIS writes in two bytes, or one in a CJK block (kana, kanji, Hangul, full-width forms), is two bytes; any other counts as LEN counts it, so without such characters each answers as the function without B (=LENB("熊本") is 4, =LENB("Aeñ") is 3). FINDB and SEARCHB take a start in bytes and answer a byte position. A count that cuts a double-byte character in half keeps a space for that half (=LEFTB("熊本",3) is 熊 ). ASC turns full-width ASCII, the ideographic space and katakana into half-width (ガ becomes ガ); DBCS and JIS turn them back. PHONETIC answers a cell's own text, as Excel does for a cell with no reading kept.
CHAR and CODE number characters by Windows-1252, as Excel for Windows does (=CHAR(128) is €); UNICHAR and UNICODE by Unicode.
VALUETOTEXT writes a value as text: a number as General writes it, TRUE or FALSE, an error as its code, and text as it is, or with format 1 in quotes, a quote inside written twice (=VALUETOTEXT("a""b",1) is "a""b"). ARRAYTOTEXT writes a range or array the same way: every element joined by a comma and a space, or with format 1 as an array constant ({1,"x";TRUE,2}), a blank cell as empty text. A format other than 0 or 1 is #VALUE!. ENCODEURL percent-encodes the UTF-8 bytes of every character but the letters A to Z and a to z, the digits, -, _, . and ~.
CONCAT joins every cell of a range or table it is given, a blank one as nothing, as TEXTJOIN with no delimiter does: =CONCAT(A1:A3,"x"). CONCATENATE takes one value in each argument and answers element by element over a range.
SEARCH ignores case and reads ? as any one character, * as any run, and ~ before either as the character itself (=SEARCH("a*c","xxabbc") is 3); FIND compares literally and with case. For both, a start_num below 1 or past the end of the text is #VALUE!.
REGEXTEST, REGEXEXTRACT and REGEXREPLACE take a regular expression. Excel reads PCRE2 patterns; these run on JavaScript's regular expressions, which share the common syntax (classes, quantifiers, groups, \d, \b, lookahead and lookbehind). As in PCRE2, a leading (?i) ignores case, (?P<name>…) names a group, \A, \z and \Z anchor to the start and end, \x{41} is a character by its code, a backslash before any symbol (\-, \") is that symbol, and a ] written first in a class ([]a], [^]]) is the character. What JavaScript does not have (possessive quantifiers, atomic groups, other inline flags) is #VALUE!, as an invalid pattern or an unknown escape such as \q is. case_sensitivity is 0 (match case, the default) or 1. REGEXEXTRACT answers the first match (return_mode 0), every match as a column (1), or the first match's groups as a row (2); no match is #N/A. Given a range of texts, each answers one value, so modes 1 and 2 give each text's first match or group, as TEXTSPLIT over a range gives each text's first piece in Excel. REGEXREPLACE replaces every match (occurrence 0), the nth, or the nth from the end (-n), and reads $1, ${name}, $0 and $$ in the replacement. A pattern that could backtrack without end is #VALUE! before it runs, since nothing can stop a regular expression once it starts and the page would freeze: one where a repeated part can be split between its repeats in more than one way, because a piece of varying length in it can take what comes after that piece (^(a+)+$, (\w+\s?)*, (.*,){5}) or two of its alternatives start with the same character ((a|ab)+). A separator the piece cannot take settles it, so (\d+\.)+\d+ and ([A-Z][a-z]+)+ run, and a refused pattern can usually be written that way: ^\w+(\s\w+)*$ for ^(\w+\s?)+$, or with a short repeat written out, ^\d{1,2}[-/]?\d{1,2}[-/]?\d{2,4}$ for ^(\d{1,2}[-/]?){2}\d{2,4}$. Outside a repeat, more than three such pieces (a?a?a?a? against many a's) are refused as well. The check is cautious: it refuses some patterns that would have finished on every text.
SPLIT, JOIN and REGEXMATCH come from Google Sheets; Excel has none of them. SPLIT(text, delimiter, [split_by_each], [remove_empty_text]) answers a row of pieces: by default it splits at each character of the delimiter (=SPLIT("a,b;c", ",;")) and drops empty pieces, while split_by_each FALSE splits at the whole delimiter and remove_empty_text FALSE keeps an empty piece between two delimiters. A piece that is a plain number, spaces around it allowed, is answered as the number (=SPLIT("1, 2", ",") gives 1 and 2); a date, a currency or a percentage stays text. An empty delimiter is #VALUE!, and no piece left is #CALC!. JOIN(delimiter, value_or_array1, …) joins values and arrays of one row or one column with the delimiter, a blank cell as empty text; a wider array is #VALUE!, and a delimiter left out (=JOIN(,A1:A3)) joins with nothing. REGEXMATCH(text, regular_expression) is TRUE when any part of the text matches, with the patterns REGEXTEST reads, so a pattern answers as it does in REGEXTEST. Sheets runs RE2, which shares the common syntax; a pattern only RE2 reads (an inline flag other than (?i)) is #VALUE! here, and one only JavaScript reads (lookaround, a backreference) answers here where Sheets refuses it; as Google documents, it reads text only, so a number is #VALUE! (=REGEXMATCH(TEXT(A1,"0"),"^4") tests a number's digits).
VALUE reads a number in brackets as negative, the way the accounting format writes it: =VALUE("(1,234.50)") is -1234.5. One already signed inside, (-5), is #VALUE!. VALUE reads numeric text as a cell does: commas only between groups of three digits, one $ at the start (a sign before or after it), a % at the end, so =VALUE("1,2,3") and =VALUE("1$234") are #VALUE!.
TEXT reads a format code's ; sections (positive;negative;zero;text), quoted and \-escaped text, _x as one space, the fill *x as x written once (TEXT's answer has no column to fill, so Excel's accounting format _($* #,##0.00_) writes $ 1,234.50; a cell's display writes it the same way), [$€-407] as its symbol, the word General (written as the General display writes a number, in at most 11 characters or with 6 digits in scientific form: =TEXT(1/3,"General") is 0.333333333, where =1/3&"" keeps 15 digits), and the @ of the text section, which writes the text itself (=TEXT("abc","""Name: ""@") is Name: abc). A colour ([Red], [Color10]) writes nothing, since TEXT's answer carries no colour. A condition ([>=1000]) chooses the section instead of the sign: the first of the first two sections whose condition holds, else the section without one or the third, so =TEXT(1500,"[>=1000]#,##0,""K"";0") is 2K. A negative number under conditions is written as the plain number, because Excel's documentation does not say whether such a section shows its minus sign. So =TEXT(-1234.5,"#,##0.00_);(#,##0.00)") is (1,234.50), and =TEXT(43832,"yyyy-mm-dd;@") is 2020-01-02. Text without a text section comes back unchanged. A section mixing date or time codes with digit placeholders is #VALUE!, as in Excel (=TEXT(41181,"mm###"), =TEXT(2,"0.00 d")); quote or escape text that holds such letters ("0.00 ""d""").
Within a number section, 0 writes a digit or 0, # a digit or nothing, and ? a digit or a space, filled from the right across any text between them (=TEXT(5551234567,"(000) 000-0000") is (555) 123-4567). A comma between placeholders groups thousands; one after the last placeholder divides by a thousand (=TEXT(1234567,"0.0,,""M""") is 1.2M). Each % multiplies by 100, and E+ or E- writes exponent form (0.00E+00, or ##0.0E+0 for an exponent that is a multiple of three). A slash between placeholders writes a fraction, the closest one whose denominator has no more digits than its placeholders (=TEXT(1.25,"# ?/?") is 1 1/4), or the numerator rounded to a written denominator (?/4); without integer placeholders it is improper (5/4). A cell's display reads fraction codes the same way. Numbers round half away from zero at Excel's 15 significant digits.
Text in a formula is written in double quotes, a quote inside it as two (="say ""hi""" is say "hi"); a backslash is an ordinary character (="C:\"&A1).
DATE, DATEDIF, DATEVALUE, DAY, DAYS, DAYS360, EDATE, EOMONTH, EPOCHTODATE, HOUR, ISOWEEKNUM, MINUTE, MONTH, NETWORKDAYS, NETWORKDAYS.INTL, NOW, SECOND, TIME, TIMEVALUE, TODAY, WEEKDAY, WEEKNUM, WORKDAY, WORKDAY.INTL, YEAR, YEARFRAC
EPOCHTODATE(timestamp, [unit]) comes from Google Sheets. It turns a Unix timestamp, in seconds (unit 1, the default), milliseconds (2) or microseconds (3), into the date and time in UTC, shown as M/D/YYYY H:MM:SS: =EPOCHTODATE(1655906710) shows 6/22/2022 14:05:10. Fractional milliseconds are dropped. A negative timestamp, or another unit (a fractional one such as 1.5 included), is #NUM!.
A formula without a format code shows its number as a date only when the number is a date by origin: the formula starts with DATE, TODAY, EDATE, EOMONTH, WORKDAY or WORKDAY.INTL, or its first reference is a date (a cell with a date format, typed as a date, or itself such a formula, on any sheet). A total that lands on 52,345 stays a number. A formula that starts with TO_DOLLARS, TO_PERCENT, TO_DATE or EPOCHTODATE shows in that function's format instead, and one that starts with TO_PURE_NUMBER never shows a date. Give a formula a format code to choose its display yourself.
A date format code is read as Excel reads it, for a cell's display and for TEXT alike: letters in any case (yyyy-mm-dd or YYYY-MM-DD), and m or mm as minutes when the part before it is an hour or the part after it a second (h:mm, h"時"mm"分"), the month otherwise. [h], [mm] and [ss] are elapsed time, the whole time in that unit: 1.5 days under [h]:mm is 36:00. A fraction of a second follows a second part with one to three 0s (h:mm:ss.000, [ss].00); the time is rounded once to the digits shown, so 59.999 seconds under mm:ss.00 is 01:00.00. A cell holding a number no date can show (below 0, or past 9999-12-31) shows ##### under a date or time code, as in Excel; TEXT answers #VALUE!.
A cell's display format with sections, a colour, _x, [$…] or quoted text is read as TEXT reads it (see Text), so Excel's own codes show as Excel shows them: #,##0.00_);[Red](#,##0.00) shows -1234.5 as (1,234.50), and yyyy-mm-dd;@ shows a date without the ;@. A colour sets no colour yet; it only no longer shows as text. A plain one-section code keeps the display's own defaults (0% shows 0.5 as 50.00%).
Dates are serial numbers in Excel's 1900 date system: serial 1 is 1900-01-01 and, as in Excel, serial 60 is a 1900-02-29 that never was, so =DATE(1900,2,28) is 59 and =DATE(1900,3,1) is 61. DATE, DATEVALUE and typed dates accept 1900-02-29, YEAR, MONTH, DAY and number formats show serial 0 as 1900-01-00, and WEEKDAY counts off the serial, so serial 1 is a Sunday. EDATE and EOMONTH step months on the real calendar (=EOMONTH(DATE(1900,2,1),0) is 59); DAYS360 and DATEDIF read February 1900 as 29 days, and DAYS360 and the bond functions read serial 0 as 1899-12-31. From 61 on, serials are the same as in LibreOffice and Google Sheets, which number the days before on the real calendar.
DATE and TIME read their parts as Excel does: each part is truncated to a whole number, a year from 0 through 1899 has 1900 added (=DATE(100,1,1) is 2000-01-01), and a year below 0 or from 10000 on, or a date that rolls over past 9999-12-31 or before serial 0, is #NUM!; a TIME part above 32767, or a time adding up to less than 0, is #NUM!.
YEAR, MONTH, DAY, HOUR, MINUTE and SECOND read a serial's time rounded to the second, so =HOUR(0.9999999) is 0 (the next midnight), and a serial no date has (below 0, or past 9999-12-31) is #NUM!.
DATEVALUE and TIMEVALUE take text, as in Excel: a date through 9999-12-31 with its month as a number or a name, the year left out meaning the current one (5-JUL), or any text a cell reads as a date (a time after it left out); a time as h:mm, h:mm:ss or h AM/h PM (a date before it left out); a number, such as a cell already holding a date, is #VALUE!.
Every other date and time function reads a date written as text as that date, and a time written as text, alone or after a date, as that serial: =HOUR("7/18/2011 7:45") is 7, =MINUTE("12:45:00 PM") is 45, and a cell holding the text 12:45 reads as a quarter to one.
NETWORKDAYS.INTL and WORKDAY.INTL take the weekend as a number (1 or left out Saturday and Sunday, 2 Sunday and Monday … 7 Friday and Saturday, 11 Sunday alone … 17 Saturday alone) or as seven 0s and 1s from Monday, 1 for a day off ("0000011"); another number is #NUM! and a malformed string #VALUE!. With every day off ("1111111") NETWORKDAYS.INTL counts 0 and WORKDAY.INTL is #VALUE!. WORKDAY and WORKDAY.INTL are #NUM! for a holiday outside Excel's dates, as Microsoft documents.
DAYS360 counts every month as 30 days, by the US method (a start on a month's last day is the 30th; an end on the 31st is the 30th only after a start on the 30th) or, with TRUE, the European one (a 31st is the 30th). YEARFRAC's basis is 0 US 30/360 (left out), 1 actual/actual, 2 actual/360, 3 actual/365 or 4 European 30/360; another basis is #NUM!, and the dates may come in either order.
AND, BYCOL, BYROW, FALSE, IF, IFERROR, IFNA, IFS, ISOMITTED, LAMBDA, LET, MAKEARRAY, MAP, NOT, OR, REDUCE, SCAN, SWITCH, TRUE, XOR
A value IF, NOT, AND, OR or XOR is given directly is read as a logical value: a number is TRUE unless 0, and text reads only when it is TRUE or FALSE (in any case), a number, or empty; other text is #VALUE! (=IF("hello",1,2)). AND, OR and XOR skip the text and blanks of a reference, a single cell as much as a range, and are #VALUE! when nothing is left to read.
ADD, DIVIDE, EQ, GT, GTE, ISBETWEEN, LT, LTE, MINUS, MULTIPLY, NE, POW, UMINUS, UNARY_PERCENT, UPLUS
Google Sheets names each operator as a function, and each answers what its operator answers on the same two values (one for UMINUS, UPLUS and UNARY_PERCENT): =ADD(A1,B1) is =A1+B1, MINUS -, MULTIPLY *, DIVIDE /, POW ^ (as POWER), EQ =, NE <>, GT >, GTE >=, LT <, LTE <=, UMINUS a leading - and UNARY_PERCENT a trailing % (=UNARY_PERCENT(93) is 0.93). Text is read as the operator reads it, an error answers as it would there (the left one first), a blank cell compares as blank (=EQ(A1,"") is TRUE for an empty A1), and an array is taken element by element. UPLUS answers its value unchanged, text included. An argument written empty is 0. Google's two-value CONCAT is the CONCAT above, which also takes more values.
ISBETWEEN comes from Google Sheets. ISBETWEEN(value_to_compare, lower_value, upper_value, [lower_value_is_inclusive], [upper_value_is_inclusive]) is TRUE when the value lies between the bounds, each end counted unless its flag is FALSE (=ISBETWEEN(1.2,1.2,12.45,FALSE) is FALSE). Its three numbers are read as ROUND reads a number, so other text is #VALUE!. Bounds the wrong way round hold nothing, and an array is taken element by element.
ADDRESS, ANCHORARRAY, AREAS, ARRAY_CONSTRAIN, ARRAYFORMULA, CHOOSE, CHOOSECOLS, CHOOSEROWS, COLUMN, COLUMNS, DROP, DROPDUPLICATES, EXPAND, FILTER, FLATTEN, GROUPBY, HLOOKUP, HSTACK, HYPERLINK, INDEX, INDIRECT, LOOKUP, MATCH, MELT, MERGE, OFFSET, PIVOTBY, QUERY, ROW, ROWS, SINGLE, SORT, SORTBY, SORTN, SPARKLINE, TAKE, TOCOL, TOROW, TRANSPOSE, TRIMRANGE, UNIQUE, VLOOKUP, VSTACK, WRAPCOLS, WRAPROWS, XLOOKUP, XMATCH
OFFSET and INDIRECT answer a reference, which every function reads as it reads one written out: =SUM(OFFSET(A1,1,0,3,1)) sums A2:A4, =ROW(INDIRECT("B3")) is 3, and =OFFSET(A1,0,0,2,2) alone spills. INDIRECT reads A1 text, R1C1 text (=INDIRECT("R2C3",FALSE), relative parts counted from the formula's cell) and other sheets, whole columns and rows included (=SUM(INDIRECT("A:A")), =SUM(INDIRECT("C2",FALSE)) for column B), each read as the same reference written out. TRIMRANGE answers a reference too: the range without its empty outer rows and columns (=SUM(TRIMRANGE(A:A))), trim_rows and trim_cols each 0 for none, 1 leading, 2 trailing or 3 both (the default), #REF! when every cell is empty; a formula cell is never empty, and the cells a table spills into are not. An array holds no empty value, so TRIMRANGE answers one as it is (=TRIMRANGE({1,2})). The spilled range reference A1# (ANCHORARRAY(A1)) is the range A1's formula answered into: the cells its table spilled into (=SUM(A1#) follows the table as it grows or shrinks), or A1 alone when it answers one value. It may name another sheet (=SUM(Data!B2#)) or a computed cell (=SUM(OFFSET(A1,1,0)#), =LET(x,A1,SUM(x#))), and is #REF! for a cell holding no formula, a reference of more than one cell, or a table that could not spill. The implicit intersection operator @ (SINGLE) picks one value: of a range, the cell on the formula's row (a range spanning rows) or in its column (one spanning columns), #VALUE! when the formula's cell lines up with none, so =@A1:A10 in row 3 is A3 and does not spill; =@A:A is the cell of column A on the formula's row. Of an array it is the first value (=@SEQUENCE(3) is 1), and of a single value that value. AREAS counts the areas of a reference: 1 for a cell or range, and the pieces of a union written in brackets (=AREAS((A1:B2,C3)) is 2). A union is read area by area by the functions that read every argument as a list of values (SUM, COUNT, COUNTA, AVERAGE, MAX, MIN, PRODUCT, MEDIAN, the STDEV, VAR, MODE and SKEW families, GCD, LCM, AND, OR, XOR and the like, and NPV and SUBTOTAL after their first argument): =SUM((A1:A2,B1)) adds all three cells. INDEX's fourth argument, area_num, picks an area of a union (=INDEX((A1:A3,B1:B3),1,1,2) is B1; #REF! past the last area), and =AREAS(INDEX(…)) is 1. A union LET, IF, IFS, CHOOSE or SWITCH answers (or a LAMBDA a LET names, called with one) is read the same way (=SUM(IF(A9>0,(A1,B1),C1))). Anywhere else a union has no value, as in Excel: =(A1,B1) and =SUMPRODUCT((A1,B1)) are #VALUE!, and =ROWS((A1,B1)) is #REF!.
SORTN, FLATTEN, ARRAY_CONSTRAIN and ARRAYFORMULA come from Google Sheets. SORTN(range, [n], [display_ties_mode], [sort_column1, is_ascending1], …) answers the first n rows (1 when left out) after a stable sort by the sort columns, each a column number in the range or a column as tall as it (any reference, a single cell too, is read as such a column), ascending unless is_ascending is FALSE; with no sort column it sorts by every column from the first. display_ties_mode 0 (the default) answers the first n rows; 1 adds the rows whose sort keys equal the nth row's; 2 leaves out a row whose sort keys equal an earlier row's; 3 answers every row whose sort keys are among the first n distinct ones, as Google's page shows for its student table. A blank cell stays blank in the rows SORTN answers, and blanks sort after every value whichever way, as Sheets sorts empty cells (errors last of all). n below 1 and a mode outside 0–3 are #NUM!, a sort column outside the range #VALUE!. FLATTEN(range1, …) answers every cell of its arguments in one column, row by row, a reference's blank cells kept blank. ARRAY_CONSTRAIN(input_range, num_rows, num_cols) answers the first num_rows rows and num_cols columns, all of a range smaller than that; a count is truncated, and below 1 or left empty it is #NUM!. ARRAYFORMULA(array_formula) answers its argument: Sheets needs it to spill an array formula or to apply a function to each cell of a range, and this engine already evaluates every formula that way, so =ARRAYFORMULA(A1:A3*2) spills as =A1:A3*2 does and =ARRAYFORMULA(SUM(A1:A3)) is one value. A function name may hold _ after its first letter, as Sheets spells ARRAY_CONSTRAIN; a custom function is still named with letters and digits.
SPARKLINE(data, [options]) comes from Google Sheets: a small chart of the data drawn inside the formula's cell.
- Value. Google does not say what the cell holds. Since the cell shows no text, other formulas read it as empty text: LEN gives 0, ISBLANK gives FALSE.
- Data. Read row by row as one series.
- Options. A table of two columns, each row a name and a value, such as
{"charttype","column";"negcolor","red"}or a range.- charttype is line (the default), bar (stacked), column or winloss.
- The other options Google documents are read: color, linewidth, xmin, xmax, ymin, ymax, max, rtl, axis, axiscolor, and the colours color1, color2, negcolor, lowcolor, highcolor, firstcolor and lastcolor.
- empty is zero or ignore, for a blank cell of a reference. nan is convert or ignore, for text, a flag or an error; as in Sheets, a formula answering empty text, or an empty text in an array, counts as text here. Both default to ignore.
- Bad options.
- An unknown name is ignored, and a value an option cannot use keeps its default.
- A colour is a
#rgbor#rrggbbcode or a CSS colour name. - An unknown charttype, or options not two columns wide, give
#VALUE!. An error in the data argument, or in an option cell, is the answer.
- Colours. In a column or winloss chart, a column takes the first colour option it qualifies for: firstcolor or lastcolor, then highcolor or lowcolor, then negcolor, then color. The colours left unset follow the light or dark theme.
- Nesting. A sparkline inside another formula is drawn only when the cell answers what SPARKLINE answered (
=IF(A1>0,SPARKLINE(B1:F1),"")), not in=LEN(SPARKLINE(B1:F1)). - Excel download. Excel has no SPARKLINE function (its sparklines are not formulas). The download writes the cell as its answer, which is blank.
A range is written A1:C10, Data!A1:C10 or 'My Sheet'!A1:C10. A whole column (A:A, B:D) or a whole row (1:1) covers its sheet as far as the data reaches, which gives the same answers, since everything past the data is blank. ROW() and COLUMN() give the number of the cell the formula is in. Given a range of several rows, ROW answers each row number, a column that spills (=ROW(A2:A4) is {2;3;4}, =SUMPRODUCT(ROW(A1:A3)) is 6), and COLUMN of several columns each column number, in a row.
CELL, ERROR.TYPE, FORMULATEXT, INFO, ISBLANK, ISERR, ISERROR, ISEVEN, ISFORMULA, ISLOGICAL, ISNA, ISNONTEXT, ISNUMBER, ISODD, ISREF, ISTEXT, N, NA, SHEET, SHEETS, T, TO_DATE, TO_DOLLARS, TO_PERCENT, TO_PURE_NUMBER, TO_TEXT, TYPE
TO_DOLLARS, TO_PERCENT, TO_DATE, TO_PURE_NUMBER and TO_TEXT come from Google Sheets.
- Each answers a value that is not a number unchanged (
=TO_DOLLARS("abc")is abc). - TO_DOLLARS, TO_PERCENT and TO_DATE answer the number itself. A formula they start shows in their format where its cell has none:
$#,##0.00,0.00%and the sheet's date.=TO_DOLLARS(2)*3shows $6.00, and=TO_DATE(25405)shows 07/21/1969. - TO_PURE_NUMBER answers the plain number:
=TO_PURE_NUMBER(A1)shows 45301 where A1 shows a date. - TO_TEXT answers a number as the text it shows as. A reference is written as its cell shows: in the cell's own format, the format its formula carries, or as a date where it shows one; a cell a table spilled into shows as its anchor would. Anything else is written in the format its own leading call carries (
=TO_TEXT(TO_PERCENT(0.5))is "50.00%"), or as General writes it.
CELL answers what this workbook holds about a cell: "address" ($B$2, with the sheet's name when it is another sheet), "col", "row", "contents", "type" (b, l or v), "prefix", "filename" (always empty text) and the number-format types "format" (F2, ",0", C2-, P0, D1 as Microsoft lists the codes), "color" and "parentheses". Left out, the reference is the formula's own cell. "width" and "protect" are #N/A, as are INFO's "directory", "origin", "osversion", "release" and "system"; INFO answers "numfile" (the number of sheets) and "recalc" (Automatic).
An argument written empty at the end of a call is read as Excel reads it where that is settled: =VLOOKUP(A1,B:C,2,), =HLOOKUP(…,) and =MATCH(A1,B:B,) match exactly, =ROUND(1.5,) rounds to 0 digits, the month of =DB(…,) and the factor of =DDB(…,) are 0, and IF, IFERROR, IFNA, IFS, CHOOSE and SWITCH answer 0 for an empty argument they answer with (=IF(FALSE,1,)). IF's value_if_false may be left out: =IF(A1>10,"High") answers FALSE when A1 is 10 or less. An empty argument anywhere in DAYS, DAYS360's start, DATEDIF's two dates, WEEKDAY, RANK's number, LARGE's k, QUARTILE's quart, TRIMMEAN's percent, BINOM.INV's probability and T.DIST is 0 (=DAYS(5,) is 5, =WEEKDAY(10,) is #NUM!); in T.DIST's cumulative it is FALSE, in TEXTJOIN's ignore_empty TRUE (=TEXTJOIN(",",,"a","","b") is a,b) and in TEXTSPLIT's col_delimiter "". Any other function reads a call ending in an empty argument as the call without it.
A blank cell is neither a number nor text, though a formula reads it as 0: =ISNUMBER(A1) and =ISTEXT(A1) are FALSE for a blank A1, =ISBLANK(A1) TRUE. The IS functions, TYPE and ERROR.TYPE answer about an error rather than with it: =ISERROR(1/0) is TRUE.
FORMULATEXT, ISFORMULA, ISREF, SHEET and SHEETS read a reference without calculating its cells, so =FORMULATEXT(A1) in A1 is no loop. FORMULATEXT gives the formula the upper-left cell holds, as written, and #N/A for a cell with none or a formula longer than 8192 characters; it and ISFORMULA are #VALUE! for an argument that is no reference, or a union. ISREF is TRUE for any reference, an OFFSET or INDIRECT call's included. SHEET numbers sheets in workbook order: this one with no argument, a reference's, or one named by text (#N/A for no such sheet); SHEETS counts the workbook's sheets, or the sheets a reference spans. A reference to a sheet that does not exist is #REF!.
An error can be written in a formula as it is shown, in any case: =IF(A1="",#N/A,A1), =IFERROR(#N/A,0). Written among the operands, it is the answer (=#DIV/0!+1 is #DIV/0!); in double quotes it is text.
BESSELI, BESSELJ, BESSELK, BESSELY, BIN2DEC, BIN2HEX, BIN2OCT, BITAND, BITLSHIFT, BITOR, BITRSHIFT, BITXOR, CONVERT, DEC2BIN, DEC2HEX, DEC2OCT, DELTA, ERF, ERF.PRECISE, ERFC, ERFC.PRECISE, GESTEP, HEX2BIN, HEX2DEC, HEX2OCT, OCT2BIN, OCT2DEC, OCT2HEX
The base conversions follow Excel's fixed widths: 10 characters of binary (10 bits), octal (30 bits) or hexadecimal (40 bits), a negative number in two's complement.
The Bessel functions take an integer order (a fraction is truncated) and answer to the last few digits, for a large x and a large order too; Excel's own values differ from the exact ones in the eighth digit or so.
Complex numbers: COMPLEX, IMABS, IMAGINARY, IMARGUMENT, IMCONJUGATE, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMDIV, IMEXP, IMLN, IMLOG10, IMLOG2, IMPOWER, IMPRODUCT, IMREAL, IMSEC, IMSECH, IMSIN, IMSINH, IMSQRT, IMSUB, IMSUM, IMTAN
A complex number is text, as in Excel: "3+4i", "3-4j", "4i", "i", "-2.5". Each part is written as General writes a number, and the answer keeps the inputs' suffix (i or j; mixing them is #VALUE!). IMSUM and IMPRODUCT take ranges and arrays.
DAVERAGE, DCOUNT, DCOUNTA, DGET, DMAX, DMIN, DPRODUCT, DSTDEV, DSTDEVP, DSUM, DVAR, DVARP
Each is D…(database, field, criteria). The field is a label or a 1-based column number. The criteria range's first row holds labels, and each row below is one alternative: a record matches when it meets every cell of any row, and a blank row matches every record. Under a label, a number or logical value matches equal values, text that begins with <, > or = compares as in SUMIFS (=Apple matches exactly), and other text matches values that begin with it. A formula under a blank label, or a label that names no field, is a computed criteria: it is written against the first record and calculated for each record, its relative rows moved down (=C2>AVERAGE($C$2:$C$9)). DGET is #VALUE! when nothing matches and #NUM! when several records do.
ANOVA.TEST, AUTOCORREL, AVEDEV, AVERAGE, AVERAGE.WEIGHTED, AVERAGEA, AVERAGEIF, AVERAGEIFS, BETA.DIST, BETA.INV, BETADIST, BETAINV, BINOM.DIST, BINOM.DIST.RANGE, BINOM.INV, BINOMDIST, CHIDIST, CHIINV, CHISQ.DIST, CHISQ.DIST.RT, CHISQ.INV, CHISQ.INV.RT, CHISQ.TEST, CHITEST, CONFIDENCE, CONFIDENCE.NORM, CONFIDENCE.T, CORREL, CORRMATRIX, COUNT, COUNTA, COUNTBLANK, COUNTIF, COUNTIFS, COUNTUNIQUE, COUNTUNIQUEIFS, COVAR, COVARIANCE.P, COVARIANCE.S, CRITBINOM, CUMPROD, CUMSUM, CUT, DECOMPOSE, DESCRIBE, DEVSQ, DIFF, EMA, EXPON.DIST, EXPONDIST, F.DIST, F.DIST.RT, F.INV, F.INV.RT, F.TEST, FDIST, FILLNA, FINV, FISHER, FISHERINV, FORECAST, FORECAST.ETS, FORECAST.ETS.CONFINT, FORECAST.ETS.SEASONALITY, FORECAST.ETS.STAT, FORECAST.LINEAR, FREQUENCY, FTEST, GAMMA, GAMMA.DIST, GAMMA.INV, GAMMADIST, GAMMAINV, GAMMALN, GAMMALN.PRECISE, GAUSS, GEOMEAN, GROWTH, HARMEAN, HYPGEOM.DIST, HYPGEOMDIST, INTERCEPT, INTERPOLATE, KENDALL, KS.TEST, KURT, LARGE, LINEST, LOGEST, LOGINV, LOGNORM.DIST, LOGNORM.INV, LOGNORMDIST, MANNWHITNEY.TEST, MARGINOFERROR, MAX, MAXA, MAXIFS, MEDIAN, MIN, MINA, MINIFS, MODE, MODE.MULT, MODE.SNGL, NEGBINOM.DIST, NEGBINOMDIST, NORM.DIST, NORM.INV, NORM.S.DIST, NORM.S.INV, NORMDIST, NORMINV, NORMSDIST, NORMSINV, OUTLIERS, PCTCHANGE, PEARSON, PERCENTILE, PERCENTILE.EXC, PERCENTILE.INC, PERCENTRANK, PERCENTRANK.EXC, PERCENTRANK.INC, PERMUTATIONA, PHI, POISSON, POISSON.DIST, PROB, QCUT, QUARTILE, QUARTILE.EXC, QUARTILE.INC, RANK, RANK.AVG, RANK.EQ, RANKS, ROLLING, RSQ, SHAPIRO.TEST, SHIFT, SKEW, SKEW.P, SLOPE, SMALL, SPEARMAN, STANDARDIZE, STDEV, STDEV.P, STDEV.S, STDEVA, STDEVP, STDEVPA, STEYX, SUM, SUMIF, SUMIFS, T.DIST, T.DIST.2T, T.DIST.RT, T.INV, T.INV.2T, T.TEST, TDIST, TINV, TREND, TRIMMEAN, TTEST, VALUECOUNTS, VAR, VAR.P, VAR.S, VARA, VARP, VARPA, WEIBULL, WEIBULL.DIST, WILCOXON.TEST, Z.TEST, ZSCORE, ZTEST
COUNTUNIQUE(value1, …) and COUNTUNIQUEIFS(range, criteria_range1, criterion1, …) come from Google Sheets: how many distinct values the arguments hold (COUNTUNIQUEIFS: in the rows of range meeting every criterion, read as COUNTIFS reads them), blank cells left out, text compared without regard to case as UNIQUE compares it, a number apart from the same digits as text. An error among the values is the answer. COUNTUNIQUEIFS is #VALUE! when a criteria range does not have the rows and columns of range, as Google requires. An empty text — a blank cell or "" — is left out like a blank.
AVERAGE.WEIGHTED and MARGINOFERROR come from Google Sheets.
AVERAGE.WEIGHTED(values, weights, [additional values, additional weights], …) is the average of the values, each weighted by its weight: =AVERAGE.WEIGHTED(B2:B6,C2:C6) gives Google's course grade, 87.7.
- Values and weights come in pairs. Each pair's two ranges or arrays have the same shape, or the answer is
#VALUE!. - A cell that is not a number (text, a blank or a logical value) leaves its pair out.
- A value written directly is read as a number.
- A negative weight is
#NUM!. Weights that add to 0 are#DIV/0!.
MARGINOFERROR(range, confidence) is Google's definition, CONFIDENCE.T(1-confidence, STDEV(range), COUNT(range)): =MARGINOFERROR({8;4;3;6},0.95) is 3.528.
VALUECOUNTS(values, [normalize]), DESCRIBE(range, [has_header]) and CORRMATRIX(range, [method], [has_header]) are not Excel functions; they take the first look at a table that pandas' value_counts(), describe() and corr() take, and spill. VALUECOUNTS answers two columns, each distinct non-blank value and its count (its share of the non-blank cells when normalize is TRUE), most frequent first and ties in order of first appearance; text is grouped without regard to case as UNIQUE groups it (pandas is case-sensitive), and nothing but blanks is #CALC!. DESCRIBE answers count, mean, std (sample), min, 25%, 50%, 75% and max of each column's numbers, the quartiles as PERCENTILE.INC computes them, under a label column; a column without numbers stays, with count 0, a mean and std of #DIV/0! and the rest #NUM!, and one number has a std of #DIV/0! (pandas' NaN). CORRMATRIX answers the correlation of every pair of columns over the rows where both hold a number, "pearson" (the default, as CORREL) or "spearman" (as Pearson's r of average ranks); a column that never varies is #DIV/0! where pandas writes NaN, and another method is #VALUE!. With has_header TRUE the first row names the columns, written above (and, for CORRMATRIX, beside) the answer. An error in the table is the answer.
ANOVA.TEST(range1, range2, …), MANNWHITNEY.TEST(range1, range2), WILCOXON.TEST(range) or WILCOXON.TEST(range1, range2) (paired), KS.TEST(range1, range2) and SHAPIRO.TEST(range) are not Excel functions: each returns a two-sided p value, choosing an exact or a normal null distribution as scipy.stats does by default.
ACCRINT, ACCRINTM, AMORDEGRC, AMORLINC, COUPDAYBS, COUPDAYS, COUPDAYSNC, COUPNCD, COUPNUM, COUPPCD, CUMIPMT, CUMPRINC, DB, DDB, DISC, DOLLARDE, DOLLARFR, DURATION, EFFECT, FV, FVSCHEDULE, INTRATE, IPMT, IRR, ISPMT, MDURATION, MIRR, NOMINAL, NPER, NPV, ODDFPRICE, ODDFYIELD, ODDLPRICE, ODDLYIELD, PDURATION, PMT, PPMT, PRICE, PRICEDISC, PRICEMAT, PV, RATE, RECEIVED, RRI, SLN, SYD, TBILLEQ, TBILLPRICE, TBILLYIELD, VDB, XIRR, XNPV, YIELD, YIELDDISC, YIELDMAT
The bond and security functions (the COUP functions, PRICE, YIELD, DURATION, MDURATION, ACCRINT, ACCRINTM, PRICEMAT, YIELDMAT, the discount functions DISC, INTRATE, RECEIVED, PRICEDISC and YIELDDISC, and the Treasury bill functions) take dates as the date functions do and a basis as YEARFRAC does: 0 US 30/360 (left out), 1 actual/actual, 2 actual/360, 3 actual/365, 4 European 30/360. Coupon dates step back from maturity by 12 / frequency months, staying on a month's last day when maturity is one. A date that is no date is #VALUE!; settlement on or after maturity, a frequency other than 1, 2 or 4, or a basis outside 0–4 is #NUM!.
ODDFPRICE, ODDFYIELD, ODDLPRICE and ODDLYIELD price a bond whose first or last period is odd, on the same bases; first_coupon must lie on the coupon schedule stepped back from maturity. AMORLINC and AMORDEGRC are the French system's depreciation: the first period prorated from purchase, then the rate on cost (AMORLINC) or, with a coefficient for the asset's life, on what is left, rounded to a whole number (AMORDEGRC). They take bases 0, 1, 3 and 4.
A formula that is a range and nothing else, such as =A1:C5 or =Data!A1:B10, answers the whole range. Its values spill from the formula's cell to the right and down, as dynamic arrays do in Excel 365. Each cell reads as =A1 would read it, so a blank cell spills as 0.
- Blocked spills. If a cell the result needs already holds something (a value, a formula, or part of another spilled result), the formula shows
#SPILL!and nothing spills. - Reading spilled cells. Other formulas read spilled cells like any others:
=B3,=SUM(B:B)and=COUNTA(B1:B9)all see them. - Formatting. A spilled cell takes its own cell's number format if it has one, and the formula cell's format otherwise.
- Saving. Only the formula is saved. The spilled values are rebuilt on every calculation.
- One value at a time. A function that takes one value in each argument, given a range or an array there, answers element by element and spills, as in Excel 365:
=IF(A1:A3>0,"Y","N"),=ROUND(B1:B9/3,1),=LEN(C1:C9),=IFERROR(1/A1:A3,""). Inside a function that reads a table, the answer is that table:=SUM(IF(A1:A9>0,B1:B9)). Arrays of different sizes line up as they do in=A1:A3*B1:C1. The functions are IF, IFERROR, IFNA, NOT, the rounding and arithmetic functions (ABS, ROUND, ROUNDUP, ROUNDDOWN, FLOOR, CEILING, ECMA.CEILING, INT, TRUNC, MOD, SQRT, POWER, EXP, LN, LOG, LOG10, SIGN, EVEN, ODD), the text functions (LEN, UPPER, LOWER, PROPER, TRIM, LEFT, RIGHT, MID, TEXT, VALUE, SUBSTITUTE, REPLACE, FIND, SEARCH, REPT, EXACT, CHAR, CODE, CONCATENATE, CLEAN, UNICHAR, UNICODE, FIXED, DOLLAR, USDOLLAR, NUMBERVALUE, T), the date parts (YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, WEEKDAY, DATE, TIME, EDATE, EOMONTH), the IS functions, ADDRESS, HYPERLINK, the trigonometric and hyperbolic functions (SIN, COS, TAN, their inverses and reciprocals, RADIANS, DEGREES, SQRTPI), and the distributions and counting functions: every.DISTand.INVfunction and its compatibility name (=NORM.S.DIST(A1:A3,TRUE),=BINOM.DIST(A1:A3,10,0.5,FALSE)), CONFIDENCE.NORM, CONFIDENCE.T, STANDARDIZE, PHI, GAUSS, FISHER, FISHERINV, GAMMA, GAMMALN, FACT, FACTDOUBLE, COMBIN, PERMUT, PERMUTATIONA and BINOM.DIST.RANGE. The tests that read a sample (T.TEST, CHISQ.TEST and the like) read their ranges whole. IFS, CHOOSE and SWITCH answer element by element over an array in an argument that decides (an IFS condition, CHOOSE's index, SWITCH's expression or a case value, never its default):=CHOOSE({1,2},B1:B9,A1:A9)puts column B before column A, so=VLOOKUP(x,CHOOSE({1,2},B1:B9,A1:A9),2,FALSE)looks to the left. With one value deciding, they answer the chosen argument whole, a range included (=CHOOSE(2,A1,B1:B3)spills B1:B3), and leave the others unevaluated.
A function can answer a table too: XLOOKUP (a whole row or column; see below), INDEX (a whole row or column for a position of 0: =SUM(INDEX(A2:D9,0,3))), GROUPBY, PIVOTBY, QUERY, DECOMPOSE, EMA, DIFF, PCTCHANGE, ROLLING, ZSCORE, OUTLIERS, RANDARRAY, FILTER, SORT, SORTBY, UNIQUE, SEQUENCE, TRANSPOSE, CHOOSECOLS, CHOOSEROWS, HSTACK, VSTACK, TAKE, DROP, MMULT, MINVERSE, MUNIT, FREQUENCY, LINEST, LOGEST, TREND and GROWTH do, and they take each other's tables (=SORT(UNIQUE(A2:A100))). An answer with no cells is #CALC!. A range argument accepts such a call, as in =SUM(…) over it.
LINEST and LOGEST fit one or more x variables by least squares (LOGEST fits ln y, so every y must be above 0). With known_y a column, each column of known_x is a variable; with known_y a row, each row is; known_x of known_y's own shape is one variable. They answer the coefficients from the last x to the first, then the constant; with stats TRUE, four more rows follow: the standard errors, r² and the standard error of y, F and the degrees of freedom, and the regression and residual sums of squares, with #N/A where a row has no more values. An x collinear with the ones before it (the constant first) is left out, with a coefficient and standard error of 0 and one more degree of freedom, as Excel documents. With a constant, an x is judged by its spread about its mean, not its size, so x far from 0 such as millisecond timestamps near 1.7E12 is kept when its values differ. A statistic that divides by 0 (no degrees of freedom, a perfect fit's F) is #NUM!. TREND and GROWTH answer the fitted line or curve at each new x, at known_x when new_x is left out. A polynomial is a fit over powers of x: =LINEST(B2:B20, A2:A20^{1,2,3}) fits a cubic, and =TREND(B2:B20, A2:A20^{1,2,3}, 8^{1,2,3}) answers it at 8. SLOPE, INTERCEPT, CORREL, RSQ, STEYX, FORECAST, TREND, the COVARIANCE functions, DEVSQ and the VAR and STDEV families keep their digits for values far from 0 against their spread, such as timestamps or IDs: their sums of deviations take out what the mean's rounding to a double adds.
GROUPBY(row_fields, values, function, [field_headers], [total_depth], [sort_order], [filter_array]) answers a row per group of row_fields (text keys compared without regard to case), each value column aggregated by function: a function's name such as SUM, AVERAGE or COUNT, or a LAMBDA of one parameter, given the group's values as a column. A function of two parameters, PERCENTOF or LAMBDA(part, whole, …), is also given the values the group's are a share of: all of the column's in GROUPBY, in PIVOTBY those of the total its relative_to names, as Excel takes them (=GROUPBY(A2:A100, B2:B100, PERCENTOF)): 0 or left out the cell's column (all of them in the Total column), 1 its row, 2 every row, 3 its row within the column's parent group, 4 its column within the row's parent group (a group's parent is its first keys less one, the whole axis for a first-level group); another number is #VALUE!. PIVOTBY(row_fields, col_fields, values, function, [field_headers], [row_total_depth], [row_sort_order], [col_total_depth], [col_sort_order], [filter_array], [relative_to]) lays the col_fields keys across the top and the row_fields keys down the side; a cell no row has both keys for is blank. Several value columns sit side by side under each column key, and the Total column then keeps its headers with its cells blank, as Excel lays it out.
- field_headers: 0 none, 1 there and hidden, 2 not there and made up (
Row Field 1,Value 1), 3 there and shown; left out, there and hidden when some value column's first cell is text and its second is not, as Excel reads it. PIVOTBY reads headers the same way; in modes 2 and 3 it shows a row naming the column fields above the column keys, and a row naming the row fields and the value columns below them. - Totals: a
Totalrow (and for PIVOTBY aTotalcolumn) by default; 0 for none, negative to put it first. GROUPBY's total_depth n also gives subtotals for the first 1 … n − 1 key columns (as many as there are), each after its rows, and the last row then saysGrand Total, as Excel's does; left out, it is 1, a grand total alone, whatever the key columns. PIVOTBY's row_total_depth and col_total_depth do the same for each axis (subtotal columns sit after their columns), as deep as that axis has key columns; deeper is#VALUE!. - sort_order: columns of the answer, 1-based, negative for descending, one or an array; left out, each key column ascending. The keys stay a hierarchy, as Excel keeps them: each key column sorts within the one before it, so GROUPBY's
{-2}sorts the second key descending under an ascending first. A value column may be named only alone ({1,-3}is#VALUE!); the groups are then ordered by it at each level, outer levels by their own aggregate. PIVOTBY's row_sort_order and col_sort_order number the key columns and then the values, which sorts by each row's or column's total. - filter_array: TRUE (or a number other than 0) for each data row to keep.
- Not supported: GROUPBY's field_relationship 1 (a flat table; 0 is read); it is
#VALUE!.
DROPDUPLICATES, MELT and MERGE are not Excel functions; they do what pandas' drop_duplicates, melt and merge do to tables, and spill.
DROPDUPLICATES(table, [columns], [keep], [has_header])answers the table's rows without duplicates, in their order (pandasdrop_duplicates(subset, keep)). Rows are compared on the given 1-based column numbers, one or an array, every column when left out; a number outside the table or not whole is#VALUE!. keep is"first"(the default) or"last"to keep that row of each set, or"none"or FALSE to drop every row that has a duplicate, in any case. Cells compare as pandas compares them: text by its exact characters ("A"and"a"differ, whereUNIQUEfinds them equal), a number never equal to text, blanks equal to each other. A logical is never equal to a number, as inUNIQUE, where pandas findsTrueequal to1. With has_header TRUE the first row is kept as it is above the rest. No row kept is#CALC!, or the header row alone.MELT(table, id_columns, [var_name], [value_name])turns a wide table into a long one (pandasmelt). The first row is the header. id_columns is how many leading columns are ids (0 for none), or one header or an array of headers; a count past the width, a fraction, a header that is not there or that more than one column has, or the same header twice is#VALUE!, as pandas refuses duplicate id columns. A value_name that is already one of the table's headers is#VALUE!too, as pandas refuses it. The answer's header is the ids' headers, var_name (variablewhen left out) and value_name (value); below it, for each other column in order, every row's ids beside that column's header and its cell, as pandas orders them. A blank cell stays blank.MERGE(left, right, left_key, [right_key], [how])joins two tables with header rows on a key column (pandasmerge). Each key is a 1-based column number or a header that only one column has; right_key is left_key when left out. how is"inner"(the default),"left","right"or"outer", in any case. Keys compare as inDROPDUPLICATES: text by its exact characters, a number never equal to text, blank keys equal to each other, and a logical never equal to a number, where pandas findsTrueequal to1. Rows come in pandas' order: the left table's rows with their matches for inner and left, the right table's for right; outer sorts by key: numbers first (a logical as 1 or 0), then text by its characters, blank keys last. When both keys have the same header the answer has one key column; otherwise both are kept. Other headers on both sides take_xand_y. A cell with no partner row is blank. A key that is not there, a key header two columns have, an unknown join, or a suffixed name that pandas refuses is#VALUE!: a suffixed name that is another column's name, unless the table already repeated that header (v,vbesidevgivesv_x,v_x,v_y, as in pandas).
An approximate match (MATCH with 1 or -1, VLOOKUP and HLOOKUP with TRUE or left out) looks only at values of the lookup value's kind — numbers, text or logicals — and passes over the others and errors, as Excel does: =MATCH(9.99E+307,A:A) finds the last number in a column that also holds text.
When XLOOKUP's return range has several rows and several columns, the answer is the whole matching row (the lookup ran down a column) or the whole matching column (it ran along a row), and it spills: =XLOOKUP("b", A2:A9, B2:D9) gives the three cells of B, C and D on the row where A holds "b". A return range of one row or one column gives one cell, as before. The return range has as many rows as a column lookup range, or as many columns as a row one, and the lookup range is one row or one column; otherwise the answer is #VALUE!, as in Excel.
QUERY(data, query, [headers]) runs a query in Google's Query Language over a table and spills the answer, as Google Sheets' QUERY does. Excel has no such function. Example: =QUERY(A1:C100, "select A, sum(C) where B > 10 group by A order by sum(C) desc limit 5").
- Clauses.
select(columns,*, and the aggregatessum,avg,count,max,min),where,group by,pivot(one column),order by(asc,desc),limit,offsetandlabel, in that order. Keywords are read in any case. - Column ids. When data is a reference, the columns are named by their sheet letters (
Bfor the first column ofB2:D9). For an array or a calculated table they areCol1,Col2… Ids are case-sensitive, and a backquoted id (`Col 1`) is read as written. where. It takes= != <> < <= > >=,is null,is not null,contains,starts with,ends with,like(%and_) andmatches(a regular expression over the whole text), joined withand,or,notand brackets. Literals are numbers, text in single or double quotes,true,falseanddate 'yyyy-mm-dd'. Text compares case and all.- Nulls and types. A comparison with a null side is unknown, as in SQL, and only rows where the condition is true are kept. Each column has the type most of its cells have; a blank, an error, or a cell of another type is null. Comparing across types, and
sumoravgover text, fail. A text test turns a number or a logical into text first, as Google documents. - The answer. Groups come in key order, and nulls sort first. The header row is the label, else the column's header, else
sum Headerfor an aggregate. For a pivot it is the pivot value, followed by the aggregate's name when there are several aggregates or a label. With several aggregates, the columns come per aggregate and then per pivot value, as Google lays them out. With no header at all, no header row is shown. - Header rows.
headersis the number of header rows, joined with spaces. Left out (or-1), there is one header row when the first row is text above a column that is not mostly text. - Errors. An answer with nothing in it is
#N/A. A query that cannot be read or run is#VALUE!. - Not supported. Arithmetic and scalar functions (
B*2,year(A),upper(A)),format,options, thedatetimeandtimeofdayliterals, more than one pivot column, and an aggregate in a pivot query'sorder by.
An array constant is written in braces: {1,2,3} is a row, {1;2;3} a column and {1,2;3,4} two rows of two. Its elements are numbers, text in double quotes, TRUE, FALSE or an error such as #N/A; anything else (a reference, a call) is #ERROR!.
An expression with a range, an array constant or a table-answering call among its operands is calculated element by element and answers a table: =A2:A9*B2:B9, =A2:A9>5, =A2:A9&"!", =SORT(A2:A9)*2. Each element reads its cell as a reference to that one cell would, so a blank cell is 0 beside * and empty text beside &. Operands of different sizes line up as in Excel: a single row or column is repeated, and past the end of a shorter operand the element is #N/A (={1,2,3}+{1,2} is {2,4,#N/A}). An element that fails, such as a division by zero, is that error, and the other elements still answer. A range read inside a call belongs to the call: =SUM(A2:A9)*2 is one number. A range argument reads such an expression's cells: =SUM(A2:A9*B2:B9), =SUMPRODUCT((A2:A9>5)*B2:B9).
A function that takes one value does not yet calculate over an array (=ABS(A2:A9), =IF(A2:A9>5,1,0)); given a table of more than one cell, it answers #VALUE!.
LET gives names to values for one formula: =LET(total, SUM(A2:A9), total / COUNT(A2:A9)). A value may use the names before it, and a name bound to a range stays that range, so =LET(x, A2:A9, SUM(x * 2)) reads its cells as a reference does. Inside a formula, a LET answering a reference reads as that reference: with B1 empty, =LET(x, B1, x)&"!" is !, as =B1&"!" is, and =LET(x, A1:A3, x)&"!" spills as =A1:A3&"!" does. A LET holding RAND, NOW, TODAY or a workbook function is read by its value. A name is letters, digits, _ and ., starting with a letter or _; one that looks like a cell (A1), a logical value, or R or C is #NAME? (so MAKEARRAY's LAMBDA names its parameters row, col, not r, c).
LAMBDA(param1, …, calculation) is a calculation over named parameters. It is called where it is written (=LAMBDA(x, x * 2)(3) is 6), through a name (=LET(f, LAMBDA(x, x * 2), f(3))), or by:
MAP(array1, [array2, …], lambda): the LAMBDA at each element, the arrays lined up as inA1:A3+B1:B3, answering a table;BYROW(array, lambda)andBYCOL(array, lambda): the LAMBDA at each row (a column of answers) or each column (a row of answers); a row given from a range is that row's range, so=BYROW(A2:C9, LAMBDA(row, MAX(row)))works asMAX(A2:C2)does;REDUCE([initial], array, lambda(accumulator, value)): the LAMBDA over every element in reading order, carrying its answer forward. An initial value left out is 0.SCAN([initial], array, lambda(accumulator, value)): asREDUCE, answering the accumulator after each element, in the array's shape:=SCAN(0, A2:A9, LAMBDA(total, x, total + x))is a running total;MAKEARRAY(rows, columns, lambda(row, column)): a table whose cells are the LAMBDA at each position, counted from 1. A size below 1 is#VALUE!.
In place of a LAMBDA, each of these takes a function's name, as Excel's eta-reduced LAMBDA: =BYROW(A2:C9, MAX) is =BYROW(A2:C9, LAMBDA(row, MAX(row))), and =REDUCE(0, A2:A9, SUM) adds them up. A name whose function cannot take that many arguments (=MAP(A2:A9, IF)) is #VALUE!, as it is for GROUPBY, PIVOTBY and ROLLING; in GROUPBY and PIVOTBY a name that holds an error answers it, so a name of no function at all is #NAME?, as Excel answers. A LAMBDA given the wrong number of arguments is #VALUE! where the call is written, inline or through a name, so =IFERROR(g(1,2),"z") answers "z"; one written but never called is #CALC!. Where one value is wanted (each element of MAP, SCAN and MAKEARRAY, each line of BYROW and BYCOL), an answer that is a table is #CALC!.
An argument written empty in a call (f(1,)) leaves its parameter out: ISOMITTED(b) is TRUE for it, so =LET(f, LAMBDA(a, b, IF(ISOMITTED(b), a, a + b)), f(1,)) is 1, and a left-out parameter used as a value reads as 0. A call with fewer arguments than parameters is #VALUE!.
RAND(), RANDBETWEEN(bottom, top) and RANDARRAY([rows], [columns], [min], [max], [whole_number]) draw from a stream seeded by where the call is: the sheet, the cell, and how many random calls that cell's formula has made before it, in the order they are evaluated. A workbook therefore calculates to the same numbers each time, and the agent and the page showing the sheet see the same table. Excel draws new numbers at every recalculation instead. RANDBETWEEN includes both bounds, rounding bottom up and top down, and is #NUM! when no whole number lies between them. RANDARRAY truncates its sizes as SEQUENCE does (0 is #CALC!, below 0 #VALUE!), and is #VALUE! when min is not below max, or when whole numbers are asked for between bounds that are not whole.
AUTOCORREL(values, lag), EMA(values, alpha), DECOMPOSE(values, period, [model]), DIFF, PCTCHANGE, ROLLING, ZSCORE, OUTLIERS, CUMSUM, CUMPROD, FILLNA, INTERPOLATE, SHIFT, RANKS, CUT and QCUT are not Excel functions; they compute what statsmodels and pandas do. A series is one row or one column of numbers in order, read as TREND and LINEST read their cells (text that is a number counts). A blank, or text that is not a number, is #VALUE! rather than skipped, since skipping would shift every point after it.
AUTOCORRELis the autocorrelation at one lag, as statsmodels'acfcomputes it.EMAis the exponential moving average (pandasewm(alpha=…, adjust=False)), one value per point; alpha must be in (0, 1].DIFF(values, [periods])is each point less the one periods before it (pandasdiff), andPCTCHANGE(values, [periods])its change as a fraction (pandaspct_change), one value per point. periods is 1 when left out, negative to look ahead, and must be a whole number; a point with none at that distance is#N/A(pandas' NaN), and a change from 0 is#DIV/0!, as=0/0is, including from 0 to 0, where pandas writes NaN. A result past the largest number is#NUM!, where pandas writes inf.ROLLING(values, window, function, [min_periods])is pandasrolling(window, min_periods).agg(function): for each point, the function over the last window points up to it, given as a column. The function is a function's name (SUM,AVERAGE,MEDIAN,STDEV, …) or aLAMBDAof one parameter, as inGROUPBY, and answers as it would for those cells (STDEVof one point is#DIV/0!). A point with fewer than min_periods points in its window (the window when left out) is#N/A. The window is a whole number from 1, and min_periods a whole number from 0 to the window.ZSCORE(values)is each value's distance from the mean in sample standard deviations, pandas'(s - s.mean()) / s.std(); with fewer than two values, or all of them equal, each point is#DIV/0!(pandas' NaN), and where the mean or the spread passes the largest number,#NUM!, as for an overflow.OUTLIERS(values, [method], [threshold])is TRUE for each value outside the fences: with"iqr"(the default), more than threshold (1.5 unless given) interquartile ranges below the lower quartile or above the upper one, the quartiles as pandas'quantileandPERCENTILE.INCcompute them; with"zscore", more than threshold (3 unless given) standard deviations from the mean, asZSCOREmeasures them. A negative threshold is#NUM!, and so is each point when the quartiles' range or the z-scores pass the largest number.CUMSUM(values)andCUMPROD(values)are the running total and running product (pandascumsum,cumprod), one value per point;CUMPROD(1 + returns)turns growth rates into an index. A running result past the largest number is#NUM!, where pandas writes inf.FILLNA(values, value_or_method)andINTERPOLATE(values)fill the gaps in a row or column, so they read it differently: a blank cell or#N/Ais a missing point (pandas' NaN), and every other cell is kept as it is.FILLNAputs the value in each missing point (pandasfillna(value)), or, given"ffill"or"bfill"in any case, the nearest known point before or after it (pandasffill,bfill); a missing point with none on that side stays#N/A. A missing fill value (a blank cell or#N/A) fills nothing, as pandas'fillna(NaN), while a typed""fills empty text; a cell holding empty text (="") reads as a blank one here, so among the values it is a missing point; another error as the fill value is the answer, and a range of more than one cell as the fill value is#VALUE!.INTERPOLATEputs each missing point on the straight line between the known points either side, by position (pandasinterpolate()): before the first known point it stays#N/A, and after the last it takes the last value, as pandas does. Its known points must be numbers (text is#VALUE!), and an error other than#N/Aamong them is the answer.SHIFT(values, [periods], [fill_value])moves a row or column along itself (pandasshift): each point takes the cell periods (1 when left out) before it, or after it for a negative distance, and a point with none at that distance gets fill_value,#N/Awhen it is left out (pandas' NaN). Any cell moves as it is, text, blanks and errors included; periods must be a whole number.RANKS(values, [method], [ascending])ranks every number of a row or column at once (pandasrank), ascending unless ascending is FALSE, where Excel'sRANK.EQandRANK.AVGrank one number at a time, descending by default. Ties take method"average"(the default),"min","max","first"(in the order they appear) or"dense"(no gaps after a tie), in any case; another method is#VALUE!. A blank or#N/Aranks#N/Aand takes no position (pandas'na_option="keep"); other text or a logical is#VALUE!, and another error is the answer.CUT(values, bins, [labels], [right])andQCUT(values, q, [labels])bin a row or column of numbers, a bin per point, as pandascutandqcut. CUT's bins is a whole number of equal-width bins over the values (the outer edge widened by a thousandth of the range, as pandas widens it) or a row or column of rising edges; its bins are right-closed(a, b]unless right is FALSE. QCUT's edges are the quantiles (asPERCENTILE.INC) at k/q, or at a row or column of fractions, and its first bin holds its lowest edge,[a, b]; edges that coincide are#NUM!, where pandas raises. labels left out names a bin by its interval, written with the edges in full (pandas rounds them for display: its(0.994, 3.0]is(0.994, 3]here, and its qcut(0.999, 4.5]is[1, 4.5]); FALSE gives the 0-based bin code, aslabels=False; a row or column gives one label per bin, and a single label is#VALUE!, as pandas refuses it. A blank, or a value in no bin, is#N/A(pandas' NaN), and text among the values is#VALUE!.DECOMPOSEis the classical decomposition (statsmodelsseasonal_decompose): for each point, its trend (a centred moving average over one period,#N/Awhere the window does not fit), seasonal and residual parts, additive by default or"multiplicative". The lag and the period must be whole numbers (a fraction is#NUM!); the period must be at least 2, with two full periods of values.
FORECAST.ETS(target_date, values, timeline, [seasonality], [data_completion], [aggregation]), FORECAST.ETS.CONFINT(target_date, values, timeline, [confidence_level], [seasonality], [data_completion], [aggregation]) and FORECAST.ETS.SEASONALITY(values, timeline, [data_completion], [aggregation]) take Excel's arguments and fit additive Holt-Winters (a level, a trend and an additive season) as Excel fits it, following formulon's reproduction of Excel (holt_winters.cpp, Apache-2.0) and checked against the answers Mac Excel 365 recorded in its oracle. The starting season comes from a moving-average decomposition and the starting trend from least squares; α, β and γ are the first of a fixed table of candidates with the least squared error, scored with the last points of the series held out. A short series is first extended along its trend.
- The timeline. The timeline can be in any order. Values at one time are combined by the aggregation: 0 or 1
AVERAGE(the default), 2COUNT, 3COUNTA, 4MAX, 5MEDIAN, 6MIN, 7SUM. The step is the gap most of the gaps share, picked from a histogram of them as Excel picks it (formulon'sets_grid.cpp); on dates, gaps of about a month, a quarter, a half-year or a year are calendar steps, so a monthly timeline steps by months of 28 to 31 days, whileFORECAST.ETS.STATreports the step in days the histogram chose. The series is rebuilt on that grid backwards from the last time; a time off the grid counts at the node nearest it. No step covering more than half the gaps is#NUM!. - Missing points. A skipped step is filled on the line between its neighbours (data_completion 1, the default) or with 0 (data_completion 0). A pair whose value or time is blank, text or a boolean is dropped, except that a blank value is 0 with data_completion 0 and text counts as 1 under
COUNTA. More than 30% of the grid filled is#NUM!. - Seasonality. 1 (the default) detects the season's length, 0 fits none, and a whole number up to 8784 gives it; one covering 70% of the series or more fits none. The length is detected as Excel detects it (formulon's
ets_detect.cpp): a periodogram of the detrended, tapered series proposes a short period, a periodogram of the standardised series proposes longer ones, each scored by the shape of the autocorrelation around its lag, and comparing amplitudes settles the choice when both are short.FORECAST.ETS.SEASONALITYanswers it, or 0 when there is none. - Statistics.
FORECAST.ETS.STAT(values, timeline, statistic_type, [seasonality], [data_completion], [aggregation])answers a statistic of the same fit: 1 alpha, 2 beta, 3 gamma, 4 MASE (the mean absolute one-step error over that of forecasting each value by the one before, 0 when the values never change), 5 SMAPE (the mean of each absolute error over the mean of the absolute value and forecast, as a fraction), 6 MAE, 7 RMSE, or 8 the timeline's step. The errors are those over the held-out points (over the whole series when it has ten points or fewer). Any other statistic_type is#NUM!. - The target. A target between two steps is read on the line between their forecasts; one within a thousandth of a step of a step is that step. On a calendar timeline the steps are whole months from the last time, and a target between two is placed in proportion to the days. A target before the last time reaches back into the series, as far as the first time. A target more than 2147483647 steps past the last time is
#NUM!. An array or range of targets answers each target in its place, as the call with that target alone answers it. - The interval.
FORECAST.ETS.CONFINTis the half-width of the interval around the forecast, at 95% unless given (0 gives a zero width). Its variance grows with each step ahead, from zero at the last time, as Excel computes it. - Errors.
#NUM!: a target a step or more before the first time, or (for the interval) at or before the last time, a seasonality, data_completion, aggregation or confidence outside its values, or no step covering most gaps.#DIV/0!: fewer than two points left.#N/A: values and timeline of different sizes.
Monthly or weekly totals need no function of their own: group by each date's month end, =GROUPBY(MAP(A2:A100, LAMBDA(d, EOMONTH(d, 0))), B2:B100, SUM) (or by each week's first day). EOMONTH takes one date, so MAP gives it each one.
A workbook can define functions of its own, for an analysis no built-in function does. Each sheet may carry an optional functions list; a function defined on any sheet is callable from every sheet of that workbook:
{
"name": "Data",
"functions": [
{
"name": "MOVING.AVG",
"params": ["values", "n"],
"body": "const xs = values.flat().filter((v) => typeof v === 'number'); const tail = xs.slice(-n); return tail.reduce((a, b) => a + b, 0) / tail.length;"
}
],
"data": [[{ "v": 100 }, { "v": "=MOVING.AVG(A1:A30, 7)" }]]
}-
A function body is JavaScript, run in QuickJS (WebAssembly) with no DOM, network, file system or timers, at most 50 ms per call, 2 s per calculation and 16 MB of memory. A body is at most 20,000 characters. Each function has a global scope of its own.
-
A function body has no regular expressions: compiling a pattern is work no time limit can stop. A body that holds a literal (
/^a+$/) is reported as not loading, and one that builds a pattern while it runs (new RegExp(...),'text'.match('b'),.search,.matchAll) shows#VALUE!. String methods that take plain text (split(','),replace('x', 'y'),replaceAll,indexOf,includes) still work, and a formula hasREGEXTEST,REGEXEXTRACTandREGEXREPLACE. -
A range argument arrives as rows of cells (an array of arrays, a blank cell as
null); a single cell and any other argument as its value. A whole column or row (A:A,2:2) arrives as the range it covers in its sheet's data. An argument that is an error is passed on without calling the function. -
Return a number, text or
true/false, or a table: an array of rows ([[1, 2], [3, 4]]), which spills like any table. A flat array is one column, and short rows are filled with#N/A. A time-out or a non-finite number shows#NUM!; a thrown error, an empty array or any other return value shows#VALUE!. In a table,nullis a blank cell and any other value that is not a number, text or a logical is a#VALUE!cell. -
A name is letters and digits, parts joined by dots, and cannot be a built-in function's.
presentSpreadsheetsays in its reply which definitions could not be used. -
presentSpreadsheet's reply also lists formula cells that calculate to an error (a few, and how many in all), so an agent can fix a workbook before handing it over: the saved file holds formulas, not results. When some of them only take their error from another (=A1*2beside an=A1that is#N/A), it names the cells the errors start from instead, each with how many others take their error from it: an error is followed into the cells a formula names (cells, ranges, other sheets, whole columns and rows) while they hold the same error. A reference built while calculating (the textINDIRECTreads, the cellsOFFSETlands on) is not followed. -
A circular reference (cells that read each other round in a loop, a cell reading itself, a range holding its own cell, or a loop through
INDIRECTorOFFSETor other sheets) shows#REF!in every cell of the loop, as Google Sheets does, and a cell reading one takes the error. The reply names each loop's cells. -
presentSpreadsheettakes an optionalexplain, a list of cells (["Summary!B4"]; a cell without a sheet name is on the first sheet; at most five). The reply explains each one, which Excel only does by hand with Trace Precedents and Evaluate Formula:- its value and its formula;
- each cell and range the formula names, with its value. Text is in quotes, so a stray space shows. A cell holding a formula shows that formula too, and a range shows its size, how many cells of each kind it holds, its first error and its first values (a range past ten thousand cells says that only the first ten thousand were looked at);
- what the formula's parts come to: the calls at its top (
=SUM(B:B)/COUNT(B:B)), or a lone call's arguments that are calculations (=IFERROR(VLOOKUP(…),0)shows the VLOOKUP). Each part is evaluated alone, in the cell's own place, soROW()and whole columns read as they do there. Nothing inside a LET or LAMBDA is evaluated, since its names mean nothing outside it.
-
presentSpreadsheetalso takesdependents, a list of cells (at most five). For each one, the reply names the formula cells that read it, directly or through other formula cells, each with its value and formula and the cell it is reached through: what a change to that cell would move. Excel shows this only by hand, one level of arrows at a time with Trace Dependents. A formula is found through the cells and ranges it names, whole columns and rows and other sheets included. References built while calculating (INDIRECT, OFFSET) are not followed, and a formula that reads only a table's spilled cells, not the cell the table spills from, is not found. The list stops after a thousand cells and says so. -
presentSpreadsheetalso takesgoalSeek: up to three requests{ "cell": "Model!C1", "value": 100, "changing": "Inputs!B1" }. Each one asks which value of the changing cell makes the formula cell equal the value, as Excel's Goal Seek does. The changing cell must hold a number or be blank. The reply gives the value found, or says plainly that none was found, with the closest value tried and the reason: a limit of calculations or time, a formula that jumps across the value, one that does not change with the cell, or one that is no number. The search starts from the cell's current value. It tries secant steps, then narrows any bracket around the value by regula falsi, and looks farther out and closer in on both sides when there is none. The workbook is not changed: the agent writes the value if it wants it. -
The reply also names cells that hold a number written as text (
"42","1,200","$5","12%"): a few, and how many in all. The workbook keeps such a cell as text, as Excel does, soSUM,AVERAGEand the other totals skip it without an error; Excel marks it with a green triangle, which an agent never sees. A code with a leading zero ("007") and a cell in the Text format ("f": "@") are left out, as text on purpose. -
presentSpreadsheetalso takesprofile:truefor every sheet, or a list of sheet names. The reply then profiles each sheet's data from the calculated values, as pandas'describe()andinfo()do:- the used range, whether row 1 reads as a header, and how many data rows there are. Row 1 is a header when it is all typed text and some cell below it is not text, so a table of text alone is read without one;
- for each column: its type (number, date, text, logical, or mixed with how many of each), distinct values, formulas (a table's spilled cells count), blanks and errors;
- the min, max and mean of its numbers, to six significant digits; the first and last of its dates; and its first distinct texts;
- problems: a header given to two columns (ignoring case), and data under a blank header.
A number is a date when its format is a date format, or when it was written as date text; a formula's date without a date format counts as a number. The profile is kept short: twenty columns a sheet at most, and the whole profile stays within a few thousand characters, columns and then sheets cut where they no longer fit. Columns and sheets left out are named, and sheets left out can be asked for by name.
-
Each workbook's functions get a QuickJS instance of their own, so a failure in one (an abort while freeing a runtime that ran out of time) cannot affect another.
-
QuickJS loads only for a workbook that defines functions. The View and
readCalculatedRangeload it themselves; a host callingcalculatedRangedirectly passes the set fromloadCustomFunctions.
# Install dependencies
yarn install
# Start dev server (http://localhost:5173/)
yarn dev
# Build
yarn build
# Type check
yarn typecheck
# Lint
yarn lintTry these prompts to test the plugin:
- "Create a budget spreadsheet with income and expenses columns"
- "Make a multiplication table from 1 to 10"
- "Create a spreadsheet to track monthly sales with SUM totals"
MIT
- Protocol spec: gui-chat-protocol
- Reference implementations using this protocol: mulmoclaude · MulmoChat