123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545 |
- /*
- Language: Excel formulae
- Author: Victor Zhou <OiCMudkips@users.noreply.github.com>
- Description: Excel formulae
- Website: https://products.office.com/en-us/excel/
- Category: enterprise
- */
- /** @type LanguageFn */
- function excel(hljs) {
- // built-in functions imported from https://web.archive.org/web/20160513042710/https://support.office.com/en-us/article/Excel-functions-alphabetical-b3944572-255d-4efb-bb96-c6d90033e188
- const BUILT_INS = [
- "ABS",
- "ACCRINT",
- "ACCRINTM",
- "ACOS",
- "ACOSH",
- "ACOT",
- "ACOTH",
- "AGGREGATE",
- "ADDRESS",
- "AMORDEGRC",
- "AMORLINC",
- "AND",
- "ARABIC",
- "AREAS",
- "ASC",
- "ASIN",
- "ASINH",
- "ATAN",
- "ATAN2",
- "ATANH",
- "AVEDEV",
- "AVERAGE",
- "AVERAGEA",
- "AVERAGEIF",
- "AVERAGEIFS",
- "BAHTTEXT",
- "BASE",
- "BESSELI",
- "BESSELJ",
- "BESSELK",
- "BESSELY",
- "BETADIST",
- "BETA.DIST",
- "BETAINV",
- "BETA.INV",
- "BIN2DEC",
- "BIN2HEX",
- "BIN2OCT",
- "BINOMDIST",
- "BINOM.DIST",
- "BINOM.DIST.RANGE",
- "BINOM.INV",
- "BITAND",
- "BITLSHIFT",
- "BITOR",
- "BITRSHIFT",
- "BITXOR",
- "CALL",
- "CEILING",
- "CEILING.MATH",
- "CEILING.PRECISE",
- "CELL",
- "CHAR",
- "CHIDIST",
- "CHIINV",
- "CHITEST",
- "CHISQ.DIST",
- "CHISQ.DIST.RT",
- "CHISQ.INV",
- "CHISQ.INV.RT",
- "CHISQ.TEST",
- "CHOOSE",
- "CLEAN",
- "CODE",
- "COLUMN",
- "COLUMNS",
- "COMBIN",
- "COMBINA",
- "COMPLEX",
- "CONCAT",
- "CONCATENATE",
- "CONFIDENCE",
- "CONFIDENCE.NORM",
- "CONFIDENCE.T",
- "CONVERT",
- "CORREL",
- "COS",
- "COSH",
- "COT",
- "COTH",
- "COUNT",
- "COUNTA",
- "COUNTBLANK",
- "COUNTIF",
- "COUNTIFS",
- "COUPDAYBS",
- "COUPDAYS",
- "COUPDAYSNC",
- "COUPNCD",
- "COUPNUM",
- "COUPPCD",
- "COVAR",
- "COVARIANCE.P",
- "COVARIANCE.S",
- "CRITBINOM",
- "CSC",
- "CSCH",
- "CUBEKPIMEMBER",
- "CUBEMEMBER",
- "CUBEMEMBERPROPERTY",
- "CUBERANKEDMEMBER",
- "CUBESET",
- "CUBESETCOUNT",
- "CUBEVALUE",
- "CUMIPMT",
- "CUMPRINC",
- "DATE",
- "DATEDIF",
- "DATEVALUE",
- "DAVERAGE",
- "DAY",
- "DAYS",
- "DAYS360",
- "DB",
- "DBCS",
- "DCOUNT",
- "DCOUNTA",
- "DDB",
- "DEC2BIN",
- "DEC2HEX",
- "DEC2OCT",
- "DECIMAL",
- "DEGREES",
- "DELTA",
- "DEVSQ",
- "DGET",
- "DISC",
- "DMAX",
- "DMIN",
- "DOLLAR",
- "DOLLARDE",
- "DOLLARFR",
- "DPRODUCT",
- "DSTDEV",
- "DSTDEVP",
- "DSUM",
- "DURATION",
- "DVAR",
- "DVARP",
- "EDATE",
- "EFFECT",
- "ENCODEURL",
- "EOMONTH",
- "ERF",
- "ERF.PRECISE",
- "ERFC",
- "ERFC.PRECISE",
- "ERROR.TYPE",
- "EUROCONVERT",
- "EVEN",
- "EXACT",
- "EXP",
- "EXPON.DIST",
- "EXPONDIST",
- "FACT",
- "FACTDOUBLE",
- "FALSE|0",
- "F.DIST",
- "FDIST",
- "F.DIST.RT",
- "FILTERXML",
- "FIND",
- "FINDB",
- "F.INV",
- "F.INV.RT",
- "FINV",
- "FISHER",
- "FISHERINV",
- "FIXED",
- "FLOOR",
- "FLOOR.MATH",
- "FLOOR.PRECISE",
- "FORECAST",
- "FORECAST.ETS",
- "FORECAST.ETS.CONFINT",
- "FORECAST.ETS.SEASONALITY",
- "FORECAST.ETS.STAT",
- "FORECAST.LINEAR",
- "FORMULATEXT",
- "FREQUENCY",
- "F.TEST",
- "FTEST",
- "FV",
- "FVSCHEDULE",
- "GAMMA",
- "GAMMA.DIST",
- "GAMMADIST",
- "GAMMA.INV",
- "GAMMAINV",
- "GAMMALN",
- "GAMMALN.PRECISE",
- "GAUSS",
- "GCD",
- "GEOMEAN",
- "GESTEP",
- "GETPIVOTDATA",
- "GROWTH",
- "HARMEAN",
- "HEX2BIN",
- "HEX2DEC",
- "HEX2OCT",
- "HLOOKUP",
- "HOUR",
- "HYPERLINK",
- "HYPGEOM.DIST",
- "HYPGEOMDIST",
- "IF",
- "IFERROR",
- "IFNA",
- "IFS",
- "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",
- "INDEX",
- "INDIRECT",
- "INFO",
- "INT",
- "INTERCEPT",
- "INTRATE",
- "IPMT",
- "IRR",
- "ISBLANK",
- "ISERR",
- "ISERROR",
- "ISEVEN",
- "ISFORMULA",
- "ISLOGICAL",
- "ISNA",
- "ISNONTEXT",
- "ISNUMBER",
- "ISODD",
- "ISREF",
- "ISTEXT",
- "ISO.CEILING",
- "ISOWEEKNUM",
- "ISPMT",
- "JIS",
- "KURT",
- "LARGE",
- "LCM",
- "LEFT",
- "LEFTB",
- "LEN",
- "LENB",
- "LINEST",
- "LN",
- "LOG",
- "LOG10",
- "LOGEST",
- "LOGINV",
- "LOGNORM.DIST",
- "LOGNORMDIST",
- "LOGNORM.INV",
- "LOOKUP",
- "LOWER",
- "MATCH",
- "MAX",
- "MAXA",
- "MAXIFS",
- "MDETERM",
- "MDURATION",
- "MEDIAN",
- "MID",
- "MIDBs",
- "MIN",
- "MINIFS",
- "MINA",
- "MINUTE",
- "MINVERSE",
- "MIRR",
- "MMULT",
- "MOD",
- "MODE",
- "MODE.MULT",
- "MODE.SNGL",
- "MONTH",
- "MROUND",
- "MULTINOMIAL",
- "MUNIT",
- "N",
- "NA",
- "NEGBINOM.DIST",
- "NEGBINOMDIST",
- "NETWORKDAYS",
- "NETWORKDAYS.INTL",
- "NOMINAL",
- "NORM.DIST",
- "NORMDIST",
- "NORMINV",
- "NORM.INV",
- "NORM.S.DIST",
- "NORMSDIST",
- "NORM.S.INV",
- "NORMSINV",
- "NOT",
- "NOW",
- "NPER",
- "NPV",
- "NUMBERVALUE",
- "OCT2BIN",
- "OCT2DEC",
- "OCT2HEX",
- "ODD",
- "ODDFPRICE",
- "ODDFYIELD",
- "ODDLPRICE",
- "ODDLYIELD",
- "OFFSET",
- "OR",
- "PDURATION",
- "PEARSON",
- "PERCENTILE.EXC",
- "PERCENTILE.INC",
- "PERCENTILE",
- "PERCENTRANK.EXC",
- "PERCENTRANK.INC",
- "PERCENTRANK",
- "PERMUT",
- "PERMUTATIONA",
- "PHI",
- "PHONETIC",
- "PI",
- "PMT",
- "POISSON.DIST",
- "POISSON",
- "POWER",
- "PPMT",
- "PRICE",
- "PRICEDISC",
- "PRICEMAT",
- "PROB",
- "PRODUCT",
- "PROPER",
- "PV",
- "QUARTILE",
- "QUARTILE.EXC",
- "QUARTILE.INC",
- "QUOTIENT",
- "RADIANS",
- "RAND",
- "RANDBETWEEN",
- "RANK.AVG",
- "RANK.EQ",
- "RANK",
- "RATE",
- "RECEIVED",
- "REGISTER.ID",
- "REPLACE",
- "REPLACEB",
- "REPT",
- "RIGHT",
- "RIGHTB",
- "ROMAN",
- "ROUND",
- "ROUNDDOWN",
- "ROUNDUP",
- "ROW",
- "ROWS",
- "RRI",
- "RSQ",
- "RTD",
- "SEARCH",
- "SEARCHB",
- "SEC",
- "SECH",
- "SECOND",
- "SERIESSUM",
- "SHEET",
- "SHEETS",
- "SIGN",
- "SIN",
- "SINH",
- "SKEW",
- "SKEW.P",
- "SLN",
- "SLOPE",
- "SMALL",
- "SQL.REQUEST",
- "SQRT",
- "SQRTPI",
- "STANDARDIZE",
- "STDEV",
- "STDEV.P",
- "STDEV.S",
- "STDEVA",
- "STDEVP",
- "STDEVPA",
- "STEYX",
- "SUBSTITUTE",
- "SUBTOTAL",
- "SUM",
- "SUMIF",
- "SUMIFS",
- "SUMPRODUCT",
- "SUMSQ",
- "SUMX2MY2",
- "SUMX2PY2",
- "SUMXMY2",
- "SWITCH",
- "SYD",
- "T",
- "TAN",
- "TANH",
- "TBILLEQ",
- "TBILLPRICE",
- "TBILLYIELD",
- "T.DIST",
- "T.DIST.2T",
- "T.DIST.RT",
- "TDIST",
- "TEXT",
- "TEXTJOIN",
- "TIME",
- "TIMEVALUE",
- "T.INV",
- "T.INV.2T",
- "TINV",
- "TODAY",
- "TRANSPOSE",
- "TREND",
- "TRIM",
- "TRIMMEAN",
- "TRUE|0",
- "TRUNC",
- "T.TEST",
- "TTEST",
- "TYPE",
- "UNICHAR",
- "UNICODE",
- "UPPER",
- "VALUE",
- "VAR",
- "VAR.P",
- "VAR.S",
- "VARA",
- "VARP",
- "VARPA",
- "VDB",
- "VLOOKUP",
- "WEBSERVICE",
- "WEEKDAY",
- "WEEKNUM",
- "WEIBULL",
- "WEIBULL.DIST",
- "WORKDAY",
- "WORKDAY.INTL",
- "XIRR",
- "XNPV",
- "XOR",
- "YEAR",
- "YEARFRAC",
- "YIELD",
- "YIELDDISC",
- "YIELDMAT",
- "Z.TEST",
- "ZTEST"
- ];
- return {
- name: 'Excel formulae',
- aliases: [
- 'xlsx',
- 'xls'
- ],
- case_insensitive: true,
- keywords: {
- $pattern: /[a-zA-Z][\w\.]*/,
- built_in: BUILT_INS
- },
- contains: [
- {
- /* matches a beginning equal sign found in Excel formula examples */
- begin: /^=/,
- end: /[^=]/,
- returnEnd: true,
- illegal: /=/, /* only allow single equal sign at front of line */
- relevance: 10
- },
- /* technically, there can be more than 2 letters in column names, but this prevents conflict with some keywords */
- {
- /* matches a reference to a single cell */
- className: 'symbol',
- begin: /\b[A-Z]{1,2}\d+\b/,
- end: /[^\d]/,
- excludeEnd: true,
- relevance: 0
- },
- {
- /* matches a reference to a range of cells */
- className: 'symbol',
- begin: /[A-Z]{0,2}\d*:[A-Z]{0,2}\d*/,
- relevance: 0
- },
- hljs.BACKSLASH_ESCAPE,
- hljs.QUOTE_STRING_MODE,
- {
- className: 'number',
- begin: hljs.NUMBER_RE + '(%)?',
- relevance: 0
- },
- /* Excel formula comments are done by putting the comment in a function call to N() */
- hljs.COMMENT(/\bN\(/, /\)/,
- {
- excludeBegin: true,
- excludeEnd: true,
- illegal: /\n/
- })
- ]
- };
- }
- export { excel as default };
|