The text of this page is from ECMA-376 5th edition Part 1 (December 2016) section 18.17, read in
full except the per-function definitions of 18.17.7 (see Not described), and from
[MS-OI29500] v20260818, notes 2.1.859 to 2.1.873. Notes marked
Excel: are Microsoft’s statements of what Office does where it differs from or
adds to the standard. How a formula is stored in a cell (the f element, shared and array
formulas) is also on the Cells page.
Syntax
The rules are written in the EBNF of ISO/IEC 14977 and are, the standard says, modified by the context-sensitive rules of the later subclauses. A formula is one expression. An expression is one of:
- an expression in parentheses;
- a constant;
- a prefix operator and an expression;
- two expressions with an infix operator between them;
- an expression and a postfix operator;
- a cell reference;
- a function call;
- a name.
A token is the smallest lexical element: constants (except an array constant), operators, cell references, function names, names and the punctuators. The punctuators are the parentheses (grouping and function calls), the comma (arguments and array constants) and the braces and semicolon (array constants). Any number of spaces (U+0020) may come before the first token or after the last, and between two tokens, except that none may separate a function name from the left parenthesis that follows it. These spaces have no meaning, but must be told apart from the space operator (intersection).
Excel: writes the same expression with the optional spaces explicit
(expression = {space}, nospace-expression, {space}) and adds
structure-reference as a kind of expression: structured references to tables are allowed
([MS-OI29500] 2.1.860 b, c; 2.1.859 a). The standard does not specify structure, conditional
formatting, data validation, name, pivot, chart, R1C1, external name or OLE link formulas; Office has its
own restrictions for each, defined in [MS-OI29500] section 3.2.3.1 (2.1.859 a to i).
Constants
| Kind | Form | Type |
|---|---|---|
| error-constant | #DIV/0!, #N/A, #NAME?, #NULL!, #NUM!, #REF!, #VALUE!, #GETTING_DATA | error |
| logical-constant | TRUE, FALSE | logical |
| numerical-constant | a whole-number part, optionally a full stop and a fractional part, optionally an exponent part (e or E, an optional + or -, digits); or a full stop and a fractional part, with the same exponent. Examples: 12, 12., .5, 1.5E-3 | number |
| string-constant | text in double quotes; a double quote inside is written twice: "ab""cd" is ab"cd; any character of the XML 1.0 production Char | text |
| array-constant | { rows }, columns separated by commas and rows by semicolons: {10,20,30,40;50,60,70,80} is 2 by 4 | array |
- An array constant shall not contain another array constant, or rows or columns of unequal length. A numerical constant inside it may be preceded by a prefix operator. Its constants may be of different types. The standard encourages implementations not to limit its rows and columns without need.
- The standard gives no preceding sign inside numerical-constant itself. Excel:
writes the constant with an optional leading
-([MS-OI29500] 2.1.861 a). - By default numbers have the precision of the XML Schema
doubletype (53 bits of mantissa); a consumer shall parse numbers of arbitrary precision without error (see Limits and precision below). - Excel: saves
#GETTING_DATAin formulas, which the standard does not list as saved (2.1.861 c).
Operators
The operators of an expression, in the order of the standard’s table (highest precedence first and lowest last; the table gives no numbers):
| Family | Operator | Meaning |
|---|---|---|
| Reference | : | Range: two cell references, one reference to the cells between them and including them. SUM(B5:C15) references 11 cells in the standard’s example. |
| comma | Union: one reference to all the cells, possibly not contiguous. The grouping parentheses are needed to show that the comma is an operator and not the argument separator: SUM((B5:B15,D5:D15)). | |
| space | Intersection: one reference to the cells common to both operands. If the intersection is empty the result is #NULL!. ((B1:C1) (C1:D1)) is C1. | |
| Arithmetic | - (prefix) | Unary minus |
% (postfix) | Percentage: divides its operand by 100 | |
^ | Exponentiation | |
*, / | Multiplication, division | |
+, - | Addition, subtraction | |
| Operators of the same precedence associate left to right; parentheses document or override the default. | ||
| Text | & | Concatenation; each operand is converted to text if necessary |
| Comparison | =, <>, <, <=, >, >= | Equal, not equal, less, less or equal, greater, greater or equal; they give TRUE or FALSE |
- The grammar’s infix operators are
:, comma, space,^,*,/,+,-,&,=,<>,<,<=,>,>=; the postfix operator is%; the prefix operator is-(Excel:+as well, 2.1.862 a). - An expression with value 0 tests logically false and one with any non-zero numeric value tests true (Excel: any non-zero numeric value, 2.1.862 b).
- If only one operand of an operator is an error value, the result is that error value. If several operands are errors and they are all the same, that error is the result; if they differ, which one is the result is unspecified.
- If the semantics of an operator with a given operand are not specified by ECMA-376 the result is
#VALUE!:"abc"+1is#VALUE!and"abc"/0is#VALUE!, not#DIV/0!.
Cell references
A reference designates one or more cells of one worksheet; a worksheet prefix lets it reach another
sheet or workbook. The form in the standard is: a name; or an optional worksheet prefix and an A1
reference; or an optional prefix and two A1 references joined by :; or the same with R1C1
references. The worksheet prefix is a sheet name and !; or two sheet names joined by
: and ! (a 3-D reference); or [workbook], two sheet names and
!; or, for names that need it, the same inside apostrophes (an apostrophe inside is doubled).
| Name | May contain |
|---|---|
| sheet name (unquoted) | any character except an operator character, ', [, ], \ and ? |
| workbook name (unquoted) | any character except an operator character, ', [, ] and ? |
| quoted sheet name | any character, operators included, except ' (which is doubled), *, [, ], \, :, / and ? |
| quoted workbook name | the same without the restriction on \ and /: not *, [, ], :, ?, and ' doubled |
- Relative, absolute and mixed: a relative reference changes along with the cell that holds the formula when that cell moves; an absolute reference does not; a mixed one has an absolute column and a relative row, or the other way round. (Excel: does not relate the behaviour of cells during move operations to relative or absolute references, 2.1.863 c.)
- External references: the workbook is not written in the formula. The Workbook part names
an
externalReferencewhose relationship leads to a Supplementary Workbook Data part (18.14); that part’sexternalBooknames a relationship of typeexternalLinkPathwhoseTargetis the full file path and whoseTargetModeisExternal. In the formula a 1-based index in square brackets stands for the workbook:SUM('C:\[Source.xlsx]Sheet1'!$A$1:$A$3)is stored asSUM([1]Sheet1!$A$1:$A$3). The part also holds a cache of the values, for when the workbook is not reachable. Excel: a non-zero index is a reference to an external book in the external link collection; the index 0 means the current workbook (2.1.863 b; 2.1.867 b). Excel writes the prefix as[index]sheet!with a sheet range allowed. - 3-D references (sheet range before the
!) work with AVERAGE, AVERAGEA, COUNT, COUNTA, MAX, MAXA, MIN, MINA, PRODUCT, STDEV, STDEVA, STDEVP, STDEVPA, SUM, VAR, VARA, VARP and VARPA, and with defined names. They shall not be used in array formulas. Excel: also with AND, AVEDEV, DEVSQ, GEOMEAN, HARMEAN, KURT, MEDIAN, NPV, OR, SKEW, SUMSQ, TRIMMEAN and ZTEST, and allows them in array or multi-cell formulas within the limits of a single-cell formula (2.1.863 d, e). - Area: a set of contiguous rectangular cells, possibly one cell. The function AREAS gives the number of areas a reference designates.
A1 style
An A1 reference is: a column, : and a column; or a row, : and a row; or a
column and a row (so B34); an absolute column or row has a $ before it.
Column letters are not case sensitive. Rows are numbered from 1 at the top, columns A to Z, then AA to AZ,
BA to BZ ... ZA to ZZ, AAA to AAZ and on. A row number shall be non-zero. A reference to a whole row is
its number, to a whole column its letter. Examples: A2, B34, B5:D8
relative; $A$2 absolute; $A2, B$34, $B5:D$8 mixed.
Excel: writes A1-cell, ":", A1-cell for a range of cells and a lone
A1-cell for one cell (2.1.864 a).
R1C1 style
In R1C1 style rows and columns are both numbered from 1. R2C2 is the second row, second
column; R[-2]C the cell two rows up in the same column; R[2]C[2] two rows down
and two columns right; R[-1] the entire row above; R the current row. An
absolute number is a non-zero digit sequence; a relative number is in brackets and may have a minus sign;
an offset of zero is the same as leaving the offset and its brackets out. The style is used only at
runtime: whichever style the workbook was saved with, cell references are stored in the XML in A1 form (see
Storage below).
Divergence: the standard says a negative offset is a row to the left or a column above
and a positive one a row to the right or a column below, which swaps rows and columns.
Excel: a negative offset is a column to the left or a row above, a positive offset a
column to the right or a row below ([MS-OI29500] 2.1.865 b). Excel writes R and
C for a relative row or column and R or C followed by a number for an
absolute one (2.1.865 a).
Names against references
Cell references range from A1 to A1048576 (column A) to XFD1 to XFD1048576 (column XFD); an
implementation may extend that range. A defined name of the form of a reference in A1 to XFD1048576 is an
error for a producer and a consumer; any other name can be defined and overrides a cell reference if
there is an ambiguity. LOG10 is always a cell reference, LOG10(...) always a
formula, and LOGO1000 can be a name (18.17.5.1).
Functions
A function call is a function name, (, an optional argument list and ). The
function name is a predefined function name, optionally with the prefix ISO. or
ECMA., or a user-defined function name (a letter followed by letters, digits and full
stops). Names are not case sensitive. A user-defined name shall not look like TRUE or
FALSE, a name or a cell reference. The meaning of a call to a user-defined function is
unspecified.
- Calls may nest. The standard encourages at least 64 levels of nesting, at least 255 arguments, and user-defined names of at least 255 characters.
- Functions with a variable number of arguments are marked by an argument list in their syntax; at least one argument shall be passed to them.
- When a function expects one value and gets several: for an array value or constant, the first element is used; for a cell range, the first element can be used or implicit intersection can be done (the standard leaves the exact behaviour unspecified). When it expects several values and gets one, the one is treated as an array of 1 by 1.
- When the type of an argument does not suit the function, the function returns
#VALUE!. - All predefined functions may be written with their plain name, with
ECMA.or withISO.in front. The one exception: the predefinedCEILINGof ECMA-376 may be used only withECMA.(it is listed asECMA.CEILING, andISO.CEILINGis a separate function). - Excel: a function always returns a result (2.1.866 b); user-defined function names
are written as a name-reference (2.1.866 a); an argument may be empty
(
argument = [expression]).
The predefined functions
Section 18.17.7 defines 356 functions, in alphabetical order from 18.17.7.1 (ABS) to 18.17.7.356 (ZTEST); each has a Syntax, argument and result description. Grouped by the standard’s own categories (18.17.7):
| Category | Functions |
|---|---|
| Cube | CUBEKPIMEMBER, CUBEMEMBER, CUBEMEMBERPROPERTY, CUBERANKEDMEMBER, CUBESET, CUBESETCOUNT, CUBEVALUE |
| Database | DAVERAGE, DCOUNT, DCOUNTA, DGET, DMAX, DMIN, DPRODUCT, DSTDEV, DSTDEVP, DSUM, DVAR, DVARP |
| Date and time | DATE, DATEDIF, DATEVALUE, DAY, DAYS360, EDATE, EOMONTH, HOUR, MINUTE, MONTH, NETWORKDAYS, NETWORKDAYS.INTL, NOW, SECOND, TIME, TIMEVALUE, TODAY, WEEKDAY, WEEKNUM, WORKDAY, WORKDAY.INTL, YEAR, YEARFRAC |
| Engineering | BESSELI, BESSELJ, BESSELK, BESSELY, BIN2DEC, BIN2HEX, BIN2OCT, COMPLEX, CONVERT, DEC2BIN, DEC2HEX, DEC2OCT, DELTA, ERF, ERFC, GESTEP, HEX2BIN, HEX2DEC, HEX2OCT, IMABS, IMAGINARY, IMARGUMENT, IMCONJUGATE, IMCOS, IMDIV, IMEXP, IMLN, IMLOG10, IMLOG2, IMPOWER, IMPRODUCT, IMREAL, IMSIN, IMSQRT, IMSUB, IMSUM, OCT2BIN, OCT2DEC, OCT2HEX |
| Financial | 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, PMT, PPMT, PRICE, PRICEDISC, PRICEMAT, PV, RATE, RECEIVED, SLN, SYD, TBILLEQ, TBILLPRICE, TBILLYIELD, VDB, XIRR, XNPV, YIELD, YIELDDISC, YIELDMAT |
| Information | CELL, ERROR.TYPE, INFO, ISBLANK, ISERR, ISERROR, ISEVEN, ISLOGICAL, ISNA, ISNONTEXT, ISNUMBER, ISODD, ISREF, ISTEXT, N, NA, TYPE |
| Logical | AND, FALSE, IF, IFERROR, NOT, OR, TRUE |
| Lookup and reference | ADDRESS, AREAS, CHOOSE, COLUMN, COLUMNS, GETPIVOTDATA, HLOOKUP, HYPERLINK, INDEX, INDIRECT, LOOKUP, MATCH, OFFSET, ROW, ROWS, RTD, TRANSPOSE, VLOOKUP |
| Math and trigonometry | ABS, ACOS, ACOSH, ASIN, ASINH, ATAN, ATAN2, ATANH, CEILING, COMBIN, COS, COSH, DEGREES, ECMA.CEILING, EVEN, EXP, FACT, FACTDOUBLE, FLOOR, GCD, INT, ISO.CEILING, LCM, LN, LOG, LOG10, MDETERM, MINVERSE, MMULT, MOD, MROUND, MULTINOMIAL, ODD, PI, POWER, PRODUCT, QUOTIENT, RADIANS, RAND, RANDBETWEEN, ROMAN, ROUND, ROUNDDOWN, ROUNDUP, SERIESSUM, SIGN, SIN, SINH, SQRT, SQRTPI, SUBTOTAL, SUM, SUMIF, SUMIFS, SUMPRODUCT, SUMSQ, SUMX2MY2, SUMX2PY2, SUMXMY2, TAN, TANH, TRUNC |
| Statistical | AVEDEV, AVERAGE, AVERAGEA, AVERAGEIF, AVERAGEIFS, BETADIST, BETAINV, BINOMDIST, CHIDIST, CHIINV, CHITEST, CONFIDENCE, CORREL, COUNT, COUNTA, COUNTBLANK, COUNTIF, COUNTIFS, COVAR, CRITBINOM, DEVSQ, EXPONDIST, FDIST, FINV, FISHER, FISHERINV, FORECAST, FREQUENCY, FTEST, GAMMADIST, GAMMAINV, GAMMALN, GEOMEAN, GROWTH, HARMEAN, HYPGEOMDIST, INTERCEPT, KURT, LARGE, LINEST, LOGEST, LOGINV, LOGNORMDIST, MAX, MAXA, MEDIAN, MIN, MINA, MODE, NEGBINOMDIST, NORMDIST, NORMINV, NORMSDIST, NORMSINV, PEARSON, PERCENTILE, PERCENTRANK, PERMUT, POISSON, PROB, QUARTILE, RANK, RSQ, SKEW, SLOPE, SMALL, STANDARDIZE, STDEV, STDEVA, STDEVP, STDEVPA, STEYX, TDIST, TINV, TREND, TRIMMEAN, TTEST, VAR, VARA, VARP, VARPA, WEIBULL, ZTEST |
| Text and data | ASC, BAHTTEXT, CHAR, CLEAN, CODE, CONCATENATE, DOLLAR, EXACT, FIND, FINDB, FIXED, JIS, LEFT, LEFTB, LEN, LENB, LOWER, MID, MIDB, PHONETIC, PROPER, REPLACE, REPLACEB, REPT, RIGHT, RIGHTB, SEARCH, SEARCHB, SUBSTITUTE, T, TEXT, TRIM, UPPER, VALUE |
The lists above were compared name by name with the category table at the end of 18.17.7 (part1.txt lines 76961 to 77101).
Excel notes on functions
- ACCRINT: Excel has an optional argument
calc-method(logical) the standard does not specify: TRUE (1) returns the total accrued interest from issue to settlement when the settlement date is later than the first-interest date; FALSE (0) returns the interest from first-interest to settlement; the default is TRUE (2.1.874 a). The further notes of 2.1.874 to 2.1.1097 on individual functions are not on this page.
Arguments that take a range
Normal and array formulas treat ranges differently:
- Array formula: every range argument is read as its full range. If the result is an
array its values are returned across all cells that share the formula. If the range of the formula is
larger than the returned array in either dimension, the extra cells take the value
#N/A. - Normal formula: implicit intersection is applied to all arguments of functions except those that allow a range; a result that is an array gives only its first value to the cell.
- Implicit intersection: when a range is passed where a single cell is expected, a test
finds whether the calling cell meets the range horizontally or vertically; if so, the cell of
intersection is passed.
ABS(B1:B3)in A2 passes B2. - Excel: when implicit intersection cannot be done the result is
#VALUE!(2.1.860 g; the standard does not say). Doubles are IEC 60559 double precision without denormalised numbers (2.1.860 d).
The standard lists, in 18.17.2, the functions whose arguments allow a range: AND, AREAS (reference), AVEDEV, AVERAGE, AVERAGEA, AVERAGEIF (all but criteria), AVERAGEIFS (all but the criteria), CELL (reference), CHITEST, COLUMN, COLUMNS, CORREL, COUNT, COUNTA, COUNTBLANK, COUNTIF (all but criteria), COUNTIFS (all but the criteria), COVAR, DAVERAGE, DCOUNT, DCOUNTA, DEVSQ, DGET, DMAX, DMIN, DPRODUCT, DSTDEV, DSTDEVP, DSUM, DVAR, DVARP, FORECAST (all but x), FREQUENCY, FTEST, FVSCHEDULE (schedule), GCD, GEOMEAN, GROWTH, HARMEAN, HLOOKUP (table_array), IMPRODUCT, IMSUM, INDEX (array or reference), INTERCEPT, LARGE (array), LCM, LINEST and LOGEST (known-xs, known-ys), LOOKUP (all but lookup_value), MATCH (lookup_array), MAX, MAXA, MDETERM (array), MEDIAN, MIN, MINA, MINVERSE, MIRR (values), MMULT, MODE, MULTINOMIAL, NETWORKDAYS (holidays), NETWORKDAYS.INTL (holidays), NPV (all but rate), OFFSET (reference), OR, PEARSON, PERCENTILE (array), PERCENTRANK (array), PROB (x_range, prob_range), PRODUCT, QUARTILE (array), RANK (ref), ROW (reference), ROWS (array), RSQ, SKEW, SLOPE, SMALL (array), STDEV, STDEVA, STDEVP, STDEVPA, STEYX, SUBTOTAL (all but function_num), SUM, SUMIF (all but criteria), SUMIFS (all but the criteria), SUMPRODUCT, SUMSQ, SUMX2MY2, SUMX2PY2, SUMXMY2, TRANSPOSE, TREND (all but const-flag), TRIMMEAN (array), TRUNC (x), TTEST (array-1, array-2), TYPE, VALUE, VAR, VARA, VARP, VARPA, VLOOKUP (table-array), WORKDAY (holidays), WORKDAY.INTL (holidays), XIRR (all but guess), XNPV (all but rate) and ZTEST (array).
Excel: defines its own, longer list ([MS-OI29500] 2.1.860 f). It adds, for example, ACCRINT, ACCRINTM, AMORDEGRC, AMORLINC, CHOOSE (all but index), KURT, T, the BESSEL, BIN2*, DEC2*, HEX2*, OCT2* and IM* families, COMPLEX, CONVERT, the COUP* family, CUBEMEMBER (member-expression), CUBESET (set-expression), CUBEVALUE (all but connection), CUMIPMT, CUMPRINC, DELTA, DISC, DOLLARDE, DOLLARFR, DURATION, EDATE, EFFECT, EOMONTH, ERF, ERFC, FACTDOUBLE, GESTEP, GETPIVOTDATA (data-field, pivot-table, field-1, item-1), IFERROR (value-if-error), INTRATE, IRR (values), ISEVEN, ISODD, ISREF, MDURATION, MROUND, N, NOMINAL, the ODD* bond functions, PHONETIC, the PRICE* functions, QUOTIENT, RANDBETWEEN, RECEIVED, SERIESSUM, SQRTPI, the TBILL* functions, WEEKNUM, YEARFRAC, YIELD, YIELDDISC and YIELDMAT (all arguments), and it does not list CELL, CHITEST, CORREL, COVAR, FORECAST, FTEST, INTERCEPT, MDETERM, MINVERSE, MMULT, MODE, NETWORKDAYS.INTL, PEARSON, PROB, RSQ, SLOPE, STEYX, SUMPRODUCT, SUMX2MY2, SUMX2PY2, SUMXMY2, TRANSPOSE, TRUNC, TTEST, TYPE, VALUE and WORKDAY.INTL, which the standard lists. The full text is in research/ooxml/ms/MS-OI29500.txt, lines 17284 to 17480.
Names
A name is an alias for a constant, a cell reference or a formula. Its syntax is an optional
workbook-name and !, a start character (a letter, _ or
\) and further characters (letters, digits, _ and a full stop). Names are not
case sensitive and are unique within a workbook. If two workbooks define the same name, a name can be
qualified with the workbook name and ! (SUM(Sales.xlsx!ProjectedSales)). A name
shall not look like TRUE or FALSE, a user-defined function name or a cell
reference. The standard encourages names of at least 255 characters.
- Excel: writes the start character as an underscore, a backslash or any code point
that is a Unicode character (chapter 4 of the Unicode Standard), and later characters may also be
digits and full stops; a name used in a formula is prefixed with the index of the external link when it
belongs to another workbook, 0 being the current workbook; Office does not create or load a name of the
form
\followed by one name character (2.1.867 a to c). - Names are stored in the Workbook part as
definedNameelements insidedefinedNames(Excel: the standard says Worksheet part; Office uses the Workbook part, 2.1.873 a). The standard also says each name shall be the subject of avt:lpstrin theTitlesOfPartsof the application properties part.
Types and values
- The types are array, error, logical, number and text. An array has one or more elements of any
types; an error has a value of error-constant; a logical has
TRUEorFALSE; a number is a real number; a text is any text. - An implementation may convert a text constant to a number implicitly; the rules are its own and may
depend on the locale (
"123"+10,"10,56"). - The standard encourages text of at least 32,767 characters. Excel: a consumer shall
treat text longer than 32767 characters as
#VALUE!(2.1.868 a). - A complex number is text in the form
x + yiorx + yj:"3+4i","-2.5-34.6j".
Single-cell and array formulas
A single-cell formula applies to one cell: a single result is that cell’s value; a multiple result
gives the first value (SIN({0.3,0.4,0.5}) gives SIN(0.3) =
0.295520207). An array formula applies to a range as a group, for returning several results from one
function (LINEST), for running one formula several times (SIN(A1:A3)), and for returning one
result from an operation that used arrays on the way (SUM(SIN(A1:A3))). A single result fills
all cells of the group. For several results:
| Group against values | Cells take |
|---|---|
| same shape | the value at the same relative position |
| fewer columns than the values | the left-most columns of the values |
| fewer rows than the values | the top-most rows of the values |
| more columns (1xN or two-dimensional values) | value at the relative position; the excess right-most cells take an unspecified value |
| more columns (Nx1 values) | the excess columns are copies of the first column |
| more rows (Nx1 or two-dimensional values) | value at the relative position; the excess bottom cells take an unspecified value |
| more rows (1xN values) | the excess rows are copies of the first row |
Excel: the excess cells of an array formula take #N/A (2.1.860 e), where the
standard in 18.17.2.7 says the value is unspecified and in 18.17.2 says #N/A: the standard
contradicts itself, and Excel follows the second.
Error values
| Value | When |
|---|---|
#DIV/0! | any number, even zero, or any error, divided by zero |
#GETTING_DATA | the value of a referenced cell has not yet been retrieved or calculated (for example when connected to an OLAP cube); unlike #N/A a value is expected to arrive. Excel: used while waiting for an asynchronous function (2.1.869 a) |
#N/A | a designated value is not available (SUMX2MY2 with arrays of different length); the function NA gives it |
#NAME? | something that looks like a name is used and no such name is defined (XYZ/3; SUM(A1C10) for A1:C10) |
#NULL! | two areas must intersect and do not (SUM(B1 C1)) |
#NUM! | an argument of the right type is outside the domain of the function (domain error), or the result cannot be represented, typically by magnitude (range error: FACT(1000)) |
#REF! | a cell reference cannot be evaluated (the row or column was deleted; OFFSET(A1,0,20000) where 20,001 columns are not supported) |
#VALUE! | an argument or operand of an incompatible type |
Each has an error-constant. ERROR.TYPE, ISERR, ISERROR and ISNA operate on error values.
Excel: [MS-XLSX] 2.3.6.1.3 defines further errors as rich values of type
_error with an errorType integer: #BLOCKED! (10, 2.3.6.1.3.1),
#BUSY! (14 or 17, 2.3.6.1.3.2), #CALC! (13, .3), #CONNECT! (9, .4),
#NAME? (4, .5), #FIELD! (12, .6), #SPILL! (8, .7),
#UNKNOWN! (11, .8), #TIMEOUT! (19, .9) and an external-service error (18, .10;
shown for example as #PYTHON!). They are not in ECMA-376.
Dates and times
- The standard says dates and times in cells are strings in ISO 8601 formats (the cell type
d; see Cells for what programs do). The earliest date is 0001-01-01T00:00, the latest 9999-12-31T23:59:59.999. Midnight is hour 0, never 24. Leap seconds are not permitted: at most 60 seconds are written in a minute (as the standard words it). - Date only:
1975-10-05. Time only:08:30,08:30:00or08:30:00.000(the separator is a full stop; fractions of a second should have no more than three decimals). Date and time:1976-11-22T08:30and its longer forms. - All dates are on the proleptic Gregorian calendar, with 1 January always the first day of the year.
- Where a calculation takes numbers and gets a date or time it uses the serial date-time, and where it gives a date or time and gets a number it reads a serial date-time. A serial date-time counts days from the base date of the date system; the fraction of a day is the time (0.5 is 12:00; a second is 1/86400). The time of day is the serial value minus the greatest integer not exceeding it, so -2.00000001 is in day -3 at time 0.99999999.
- 1900 system: base date 30 December 1899 (serial 0); 1 January 0001 is -693593; 31
December 9999 23:59:59.999 is 2,958,465.9999884. 1904 system: base date 1 January 1904;
the lower limit is -695055 and the upper 2,957,003.9999884. A serial value outside the range of the
chosen system is invalid. The system is chosen by
date1904onworkbookPr. - Examples from the standard, 1900 system: 1.5 is 1899-12-31T12:00; -4.25 is 1899-12-25T18:00; -1.25 is 1899-12-28T18:00; -2337.999989 is 1893-08-05T00:00:01; 3687.4207639 is 1910-02-03T10:05:54; 2.5 is 1900-01-01T12:00. In the 1904 system: -3799.999989 is 1893-08-05T00:00:01; 2225.4207639 is 1910-02-03T10:05:54; 0.5 is 1904-01-01T12:00.
- The viewer’s treatment of the 1900 leap-year error is on the overview.
Limits and precision
- The value space is the values (-1)s × m × 2n with s 0 or 1, m an integer from 0 up to but not including 253 (the binary mantissa), and n an integer from -1074 to 971 inclusive (the binary exponent). The default is patterned after the IEC 60559 double. An implementation may replace it with a value space stated in the characteristics markup (22.7).
- A number’s lexical form is a decimal mantissa, optionally followed by
Eoreand an integer exponent (exponent 0 when omitted):-1E4,1267.43233E12,12.78e-2,-0. A leading sign is optional (+ assumed); an integer is a run of digits; a decimal has a full stop and leading and trailing zeros are optional. Negative zero is allowed. - Interpretation: the raw value is the mantissa times 10 to the exponent. If its absolute value is larger
than the largest value of the space (21024 minus 2971), a consumer treats it as
#NUM!; otherwise the closest value in the space is chosen, and when two are equally close the one of smaller absolute value. So4503599627370497.5is the same as4503599627370497(252 + 1). - Excel: m is an integer with absolute value from 252 up to but not including 253 and n runs from -1074 to 971 (the standard in Part 1 18.17.5.2 already says -1074 and 971; [MS-OI29500] 2.1.870 a quotes -1075 to 970 for the standard, which differs from the text read here); denormalised numbers are excluded (2.1.870 b). The largest value is 21024 - 2971, the smallest negative -21024 + 2971, and the smallest positive 2-1022 (the standard text read here already gives the first; 2.1.871 a quotes 21023 - 1). When the absolute value is smaller than the smallest positive value a consumer treats it as 0 (2.1.871 b).
How formulas are stored
- Reference style: a workbook saved in A1 style has
refModeofcalcPromitted orA1; one saved in R1C1 style hasrefMode="R1C1". Whichever it is, cell references are stored in A1 form; the attribute tells the application which style to show. - Scalar formula: an
felement holding the formula text (no=) and avelement holding the last computed value, both inside thecof arow. A string result hast="str"on the cell. - Array formula: an
felement witht="array". A single-cell array formula hasrnaming that cell. For several cells, the top-left cell’srgives the range; the other cells of the range have nofbut each has av. Excel: the standard saysrin several places; Office uses therefattribute (2.1.872 a) (see the Cells page for the attribute list off). - Evaluation order: the order of the
celements in thecalcChainof the Calculation Chain part (18.6.2). - Value representation in
v: array, the text form of the value; error, the text of the error; logical,0for FALSE and1for TRUE; number, the unformatted text as accurately as possible; text, all the characters. - Names: see the section on names above.
- Dates: a date-time cell holds an ISO 8601 string (the example in the standard is
<c t="d"><f>DATE(1582,10,15)+0.5</f><v>1582-10-15T12:00</v></c>).
In the viewer
The explorer reads every formula into a tree (explorer/formats/xlsx/formula.js) and writes
it back as a self-check; it never evaluates it. It reads numbers, strings, booleans, error literals, cell,
range, whole-column and whole-row references (relative or absolute), sheet-qualified references (quoted,
3-D and [n] external), defined names, structured table references, function calls, array
constants, the prefix - and +, the postfix %, all infix operators
including range, intersection and union, and parentheses. It does not read R1C1 notation. The Formulas
view lists, per cell, the formula, its outline, the functions, references and names used, and why a
formula could not be read.
Not described on this page
- The definitions of the 356 functions in 18.17.7 (syntax, arguments, results and examples of each).
- The [MS-OI29500] notes on individual functions (2.1.874 to 2.1.1097).
- The Office restrictions for structure, conditional formatting, data validation, name, pivot, chart, R1C1, external name and OLE link formulas ([MS-OI29500] 3.2.3.1).
- The text of the characteristics markup (22.7).
Sources
- ECMA-376 5th edition Part 1 section 18.17 (18.17.1 to 18.17.7 and the category table), in the project’s research/ooxml/ecma376/p1/part1.txt, lines 75704 to 77101
- [MS-OI29500] v20260818, research/ooxml/ms/MS-OI29500.txt, notes 2.1.859 to 2.1.874 (lines 17195 to 17816)
- The viewer code explorer/formats/xlsx/formula.js