Skip to content

RobinMalfait/spreadsheet

Repository files navigation

Spreadsheet

I... I don't know why I made this exactly. One day, I thought, "Would I be able to build spreadsheet software?" And then I did it.

You can find the application: https://spreadsheet.robinmalfait.com

Features

General

  • You can write normal text in a cell
  • You can write a number in a cell
    • This is actual text, but will be coerced to a number
  • You can write a formula in a cell
    • Formulas are prefixed with =

Once you write a formula, you will get some syntax highlighting.

Operators

Mathematical Operators

Operator Description
+ Addition
- Subtraction
* Multiplication
/ Division
^ Exponentiation
( and ) Parentheses

Comparison Operators

Operator Description
== Equal
!= Not equal
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal

Functions

There are 123 built-in functions available.

Date functions

ADD_DAYS(date: DATETIME, days: NUMBER)

Back to top

Add a certain amount of days to a date.

  • date: The date to add the days to.
  • days: The number of days to add.

Example:

// Dependencies:
=TODAY() // 2013-01-21

=ADD_DAYS(TODAY(), 7)
// 2013-01-28

ADD_HOURS(date: DATETIME, hours: NUMBER)

Back to top

Add a certain amount of hours to a date.

  • date: The date to add the hours to.
  • days: The number of hours to add.

Example:

// Dependencies:
=NOW() // 2013-01-21 08:15:20

=ADD_HOURS(NOW(), 8)
// 2013-01-21 16:15:20

DAY(date: DATETIME)

Back to top

The current day of the given date.

  • date: The date to extract the current day from.

Example:

// Dependencies:
=TODAY() // 2013-01-21

=DAY(TODAY())
// 21

HOUR(date: DATETIME)

Back to top

The current hour of the given date.

  • date: The date to extract the current hour from.

Example:

// Dependencies:
=NOW() // 2013-01-21 08:15:20

=HOUR(NOW())
// 8

MINUTE(date: DATETIME)

Back to top

The current minute of the given date.

  • date: The date to extract the current minute from.

Example:

// Dependencies:
=NOW() // 2013-01-21 08:15:20

=MINUTE(NOW())
// 15

MONTH(date: DATETIME)

Back to top

The current month of the given date. The month is 1-indexed.

  • date: The date to extract the current month from.

Example:

// Dependencies:
=TODAY() // 2013-01-21

=MONTH(TODAY())
// 1

NOW()

Back to top

The current date and time represented as a datetime.

Example:

=NOW()
// 2013-01-21 08:15:20

SECOND(date: DATETIME)

Back to top

The current second of the given date.

  • date: The date to extract the current seconds from.

Example:

// Dependencies:
=NOW() // 2013-01-21 08:15:20

=SECOND(NOW())
// 20

SUB_DAYS(date: DATETIME, days: NUMBER)

Back to top

Subtract a certain amount of days from a date.

  • date: The date to subtract the days from.
  • days: The number of days to subtract.

Example:

// Dependencies:
=TODAY() // 2013-01-21

=SUB_DAYS(TODAY(), 7)
// 2013-01-14

SUB_HOURS(date: DATETIME, hours: NUMBER)

Back to top

Subtract a certain amount of hours from a date.

  • date: The date to subtract the hours from.
  • days: The number of hours to subtract.

Example:

// Dependencies:
=NOW() // 2013-01-21 08:15:20

=SUB_HOURS(NOW(), 8)
// 2013-01-21 00:15:20

TIME()

Back to top

The current time represented as a datetime.

Example:

=TIME()
// 08:15:20

TODAY()

Back to top

The current date represented as a datetime.

Example:

=TODAY()
// 2013-01-21

YEAR(date: DATETIME)

Back to top

The current year of the given date.

  • date: The date to extract the current year from.

Example:

// Dependencies:
=TODAY() // 2013-01-21

=YEAR(TODAY())
// 2013

Engineering functions

BIN2DEC(value: STRING | NUMBER)

Back to top

Convert a binary number to decimal

  • value: The binary number to convert.

Example:

=BIN2DEC(1101)
// 13

BIN2HEX(value: STRING | NUMBER)

Back to top

Convert a binary number to hexadecimal

  • value: The binary number to convert.

Example:

=BIN2HEX(1101)
// "d"

BIN2OCT(value: STRING | NUMBER)

Back to top

Convert a binary number to octal

  • value: The binary number to convert.

Example:

=BIN2OCT(111111111)
// "777"

DEC2BIN(value: NUMBER)

Back to top

Convert a decimal number to binary

  • value: The decimal number to convert.

Example:

=DEC2BIN(13)
// "1101"

DEC2HEX(value: NUMBER)

Back to top

Convert a decimal number to binary

  • value: The decimal number to convert.

Example:

=DEC2HEX(13)
// "d"

DEC2OCT(value: NUMBER)

Back to top

Convert a decimal number to binary

  • value: The decimal number to convert.

Example:

=DEC2OCT(13)
// "15"

HEX2BIN(value: STRING | NUMBER)

Back to top

Convert a decimal number to binary

  • value: The hexadecimal number to convert.

Examples:

=HEX2BIN("FF")
// "11111111"
=HEX2BIN("1234")
// "1001000110100"

HEX2DEC(value: STRING | NUMBER)

Back to top

Convert a decimal number to binary

  • value: The hexadecimal number to convert.

Examples:

=HEX2DEC("FF")
// 255
=HEX2DEC("1234")
// 4660

HEX2OCT(value: STRING | NUMBER)

Back to top

Convert a decimal number to binary

  • value: The hexadecimal number to convert.

Examples:

=HEX2OCT("FF")
// "377"
=HEX2OCT("1234")
// "11064"

OCT2BIN(value: STRING | NUMBER)

Back to top

Convert a decimal number to binary

  • value: The octal number to convert.

Example:

=OCT2BIN(777)
// "111111111"

OCT2DEC(value: STRING | NUMBER)

Back to top

Convert an octal number to hexadecimal

  • value: The octal number to convert.

Example:

=OCT2DEC(777)
// 511

OCT2HEX(value: STRING | NUMBER)

Back to top

Convert an octal number to hexadecimal

  • value: The octal number to convert.

Example:

=OCT2HEX(777)
// "1ff"

Logic functions

AND(...expressions: T)

Back to top

Returns true if all conditions are true.

  • expressions: The conditions to evaluate.

Examples:

// Dependencies:
=TRUE() // TRUE

=AND(TRUE(), TRUE(), TRUE())
// TRUE
// Dependencies:
=TRUE() // TRUE
=FALSE() // FALSE

=AND(TRUE(), TRUE(), FALSE())
// FALSE

BIT_AND(lhs: NUMBER, rhs: NUMBER)

Back to top

Returns the bitwise AND of two numbers.

  • lhs: The left hand side of the operation.
  • rhs: The right hand side of the operation.

Example:

=BIT_AND(5, 3)
// 1

BIT_LSHIFT(value: NUMBER, amount: NUMBER)

Back to top

Returns the bitwise left shift of a number.

  • value: The number to shift.
  • amount: The number of bits to shift.

Example:

=BIT_LSHIFT(5, 3)
// 40

BIT_OR(lhs: NUMBER, rhs: NUMBER)

Back to top

Returns the bitwise OR of two numbers.

  • lhs: The left hand side of the operation.
  • rhs: The right hand side of the operation.

Example:

=BIT_OR(5, 3)
// 7

BIT_RSHIFT(value: NUMBER, amount: NUMBER)

Back to top

Returns the bitwise left shift of a number.

  • value: The number to shift.
  • amount: The number of bits to shift.

Example:

=BIT_RSHIFT(128, 2)
// 32

BIT_XOR(lhs: NUMBER, rhs: NUMBER)

Back to top

Returns the bitwise XOR of two numbers.

  • lhs: The left hand side of the operation.
  • rhs: The right hand side of the operation.

Example:

=BIT_XOR(5, 3)
// 6

FALSE()

Back to top

The boolean value false.

Example:

=FALSE()
// FALSE

IF(test: BOOLEAN, consequent: T, alternate: T)

Back to top

Returns one value if a condition is true and another value if it is false.

  • test: The condition to evaluate.
  • consequent: The value to return if the condition is true.
  • alternate: The value to return if the condition is false.

Examples:

// Dependencies:
=TRUE() // TRUE

=IF(TRUE(), "huge if true", "huge if false")
// "huge if true"
// Dependencies:
=FALSE() // FALSE

=IF(FALSE(), "huge if true", "huge if false")
// "huge if false"

IF_ERROR(value: T, fallback: T)

Back to top

Returns one value if a condition is an error and another value if it is not.

  • value: The value to test against an error.
  • fallback: The value to return if the condition is an error.

Examples:

=IF_ERROR(123 / 1, 0)
// 123
=IF_ERROR(123 / 0, 0)
// 0

NOT(value: BOOLEAN)

Back to top

Returns true if the condition is false.

  • value: The condition to negate.

Examples:

// Dependencies:
=TRUE() // TRUE

=NOT(TRUE())
// FALSE
// Dependencies:
=FALSE() // FALSE

=NOT(FALSE())
// TRUE

OR(...expressions: T)

Back to top

Returns true if any condition is true.

  • expressions: The conditions to evaluate.

Examples:

// Dependencies:
=TRUE() // TRUE

=OR(TRUE(), TRUE(), TRUE())
// TRUE
// Dependencies:
=TRUE() // TRUE
=FALSE() // FALSE

=OR(TRUE(), TRUE(), FALSE())
// TRUE

SWITCH(value: T, ...cases: T, default?: T)

Back to top

Returns the matching value for the first condition that is true.

  • value: The value to test against the conditions.
  • cases: The cases and the values to return.

Examples:

=SWITCH(1, 1, "st", 2, "nd", 3, "rd", "th")
// "st"
=SWITCH(2, 1, "st", 2, "nd", 3, "rd", "th")
// "nd"
=SWITCH(3, 1, "st", 2, "nd", 3, "rd", "th")
// "rd"
=SWITCH(4, 1, "st", 2, "nd", 3, "rd", "th")
// "th"
=SWITCH(5, 1, "st", 2, "nd", 3, "rd", "th")
// "th"

TRUE()

Back to top

The boolean value true.

Example:

=TRUE()
// TRUE

Lookup functions

LOOKUP(value: T, lhs: T | T[], rhs: T | T[], fallback?: T)

Back to top

Lookup a value in a range, and return the value in the same position from another range.

Example:

// Dependencies:
=RANGE(1, 3)
// ┌───┬───┬───┐
// │   │ A │ B │
// ├───┼───┼───┤
// │ 1 │ 1 │ 2 │
// └───┴───┴───┘
=RANGE(4, 6)
// ┌───┬───┬───┐
// │   │ A │ B │
// ├───┼───┼───┤
// │ 1 │ 4 │ 5 │
// └───┴───┴───┘

=LOOKUP(2, RANGE(1, 3), RANGE(4, 6))
// 5

Math functions

ABS(x: NUMBER)

Back to top

The ABS function.

  • x: A number.

Example:

=ABS(1)
// 1

ACOS(x: NUMBER)

Back to top

The ACOS function.

  • x: A number.

Example:

=ACOS(1)
// 0

ACOSH(x: NUMBER)

Back to top

The ACOSH function.

  • x: A number.

Example:

=ACOSH(1)
// 0

ADD(x: NUMBER, y: NUMBER)

Back to top

Add two numbers.

  • x: The first number.
  • y: The second number.

Example:

=ADD(1, 2)
// 3

ASIN(x: NUMBER)

Back to top

The ASIN function.

  • x: A number.

Example:

=ASIN(1)
// 1.5707963267948966

ASINH(x: NUMBER)

Back to top

The ASINH function.

  • x: A number.

Example:

=ASINH(1)
// 0.881373587019543

ATAN(x: NUMBER)

Back to top

The ATAN function.

  • x: A number.

Example:

=ATAN(1)
// 0.7853981633974483

ATAN2(y: NUMBER, x: NUMBER)

Back to top

The angle (in radians) from the X axis to a point.

  • y: A numeric expression representing the cartesian y-coordinate.
  • x: A numeric expression representing the cartesian x-coordinate.

Example:

=ATAN2(1, 1)
// 0.7853981633974483

ATANH(x: NUMBER)

Back to top

The ATANH function.

  • x: A number.

Example:

=ATANH(1)
// Infinity

CBRT(x: NUMBER)

Back to top

The CBRT function.

  • x: A number.

Example:

=CBRT(1)
// 1

CEIL(x: NUMBER)

Back to top

Returns the smallest integer greater than or equal to its numeric argument.

  • x: A numeric expression.

Example:

=CEIL(1.5)
// 2

CLZ32(x: NUMBER)

Back to top

The CLZ32 function.

  • x: A number.

Example:

=CLZ32(1)
// 31

COS(x: NUMBER)

Back to top

The COS function.

  • x: A number.

Example:

=COS(1)
// 0.5403023058681398

COSH(x: NUMBER)

Back to top

The COSH function.

  • x: A number.

Example:

=COSH(1)
// 1.5430806348152437

DIVIDE(x: NUMBER, y: NUMBER)

Back to top

Returns the result of dividing two numbers.

  • x: The dividend.
  • y: The divisor.

Example:

=DIVIDE(6, 3)
// 2

EXP(x: NUMBER)

Back to top

The EXP function.

  • x: A number.

Example:

=EXP(1)
// 2.718281828459045

FLOOR(x: NUMBER)

Back to top

Returns the greatest integer less than or equal to its numeric argument.

  • x: A numeric expression.

Example:

=FLOOR(1.5)
// 1

IMUL(x: NUMBER, y: NUMBER)

Back to top

The result of 32-bit multiplication of two numbers.

  • x: First number
  • y: Second number

Example:

=IMUL(1, 2)
// 2

LOG(x: NUMBER)

Back to top

The LOG function.

  • x: A number.

Example:

=LOG(1)
// 0

LOG10(x: NUMBER)

Back to top

The LOG10 function.

  • x: A number.

Example:

=LOG10(1)
// 0

MOD(x: NUMBER, y: NUMBER)

Back to top

Returns the remainder of the division of two numbers.

  • x: The dividend.
  • y: The divisor.

Example:

=MOD(5, 2)
// 1

MULTIPLY(x: NUMBER, y: NUMBER)

Back to top

Multiply two numbers.

  • x: The first number.
  • y: The second number.

Example:

=MULTIPLY(2, 3)
// 6

PI()

Back to top

The number π.

Example:

=PI()
// 3.141592653589793

POWER(x: NUMBER, y: NUMBER)

Back to top

Returns the value of a base expression taken to a specified power.

  • x: The base value of the expression.
  • y: The exponent value of the expression.

Example:

=POWER(2, 3)
// 8

PRODUCT(...values: T)

Back to top

Returns the product of all arguments.

  • values: The numbers to multiply.

Example:

=PRODUCT(2, 3, 4)
// 24

ROUND(x: NUMBER, places?: NUMBER)

Back to top

Rounds a number to a certain number of decimal places.

  • value: The number to round.
  • places: The number of decimal places to round to.

Examples:

=ROUND(1.5)
// 2
// Dependencies:
=PI() // 3.141592653589793

=ROUND(PI(), 2)
// 3.14

SIN(x: NUMBER)

Back to top

The SIN function.

  • x: A number.

Example:

=SIN(1)
// 0.8414709848078965

SINH(x: NUMBER)

Back to top

The SINH function.

  • x: A number.

Example:

=SINH(1)
// 1.1752011936438014

SQRT(x: NUMBER)

Back to top

The SQRT function.

  • x: A number.

Example:

=SQRT(1)
// 1

SUBTRACT(x: NUMBER, y: NUMBER)

Back to top

Subtract two numbers.

  • x: The first number.
  • y: The second number.

Example:

=SUBTRACT(2, 1)
// 1

SUM(...values: T)

Back to top

Returns the sum of all arguments.

  • values: The numbers to sum.

Example:

=SUM(1, 2, 3)
// 6

TAN(x: NUMBER)

Back to top

The TAN function.

  • x: A number.

Example:

=TAN(1)
// 1.557407724654902

TANH(x: NUMBER)

Back to top

The TANH function.

  • x: A number.

Example:

=TANH(1)
// 0.7615941559557649

TAU()

Back to top

The number τ.

Example:

=TAU()
// 6.283185307179586

TRUNC(x: NUMBER)

Back to top

The TRUNC function.

  • x: A number.

Example:

=TRUNC(1)
// 1

Sequence functions

ASCII_LETTERS()

Back to top

A sequence of ascii letters from a through z and A through Z.

Example:

=ASCII_LETTERS()
// ┌───┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐
// │   │ A   │ B   │ C   │ D   │ E   │ F   │ G   │ H   │ I   │ J   │ K   │ L   │ M   │ N   │ O   │ P   │ Q   │ R   │ S   │ T   │ U   │ V   │ W   │ X   │ Y   │ Z   │ [   │ \   │ ]   │ ^   │ _   │ `   │ a   │ b   │ c   │ d   │ e   │ f   │ g   │ h   │ i   │ j   │ k   │ l   │ m   │ n   │ o   │ p   │ q   │ r   │ s   │ t   │
// ├───┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
// │ 1 │ "a" │ "b" │ "c" │ "d" │ "e" │ "f" │ "g" │ "h" │ "i" │ "j" │ "k" │ "l" │ "m" │ "n" │ "o" │ "p" │ "q" │ "r" │ "s" │ "t" │ "u" │ "v" │ "w" │ "x" │ "y" │ "z" │ "A" │ "B" │ "C" │ "D" │ "E" │ "F" │ "G" │ "H" │ "I" │ "J" │ "K" │ "L" │ "M" │ "N" │ "O" │ "P" │ "Q" │ "R" │ "S" │ "T" │ "U" │ "V" │ "W" │ "X" │ "Y" │ "Z" │
// └───┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘

ASCII_LETTERS_LOWERCASE()

Back to top

A sequence of ascii letters from a through z

Example:

=ASCII_LETTERS_LOWERCASE()
// ┌───┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐
// │   │ A   │ B   │ C   │ D   │ E   │ F   │ G   │ H   │ I   │ J   │ K   │ L   │ M   │ N   │ O   │ P   │ Q   │ R   │ S   │ T   │ U   │ V   │ W   │ X   │ Y   │ Z   │
// ├───┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
// │ 1 │ "a" │ "b" │ "c" │ "d" │ "e" │ "f" │ "g" │ "h" │ "i" │ "j" │ "k" │ "l" │ "m" │ "n" │ "o" │ "p" │ "q" │ "r" │ "s" │ "t" │ "u" │ "v" │ "w" │ "x" │ "y" │ "z" │
// └───┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘

ASCII_LETTERS_UPPERCASE()

Back to top

A sequence of ascii letters from A through Z

Example:

=ASCII_LETTERS_UPPERCASE()
// ┌───┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐
// │   │ A   │ B   │ C   │ D   │ E   │ F   │ G   │ H   │ I   │ J   │ K   │ L   │ M   │ N   │ O   │ P   │ Q   │ R   │ S   │ T   │ U   │ V   │ W   │ X   │ Y   │ Z   │
// ├───┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
// │ 1 │ "A" │ "B" │ "C" │ "D" │ "E" │ "F" │ "G" │ "H" │ "I" │ "J" │ "K" │ "L" │ "M" │ "N" │ "O" │ "P" │ "Q" │ "R" │ "S" │ "T" │ "U" │ "V" │ "W" │ "X" │ "Y" │ "Z" │
// └───┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘

DIGITS()

Back to top

A sequence of the digits from 0 through 9.

Example:

=DIGITS()
// ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
// │   │ A │ B │ C │ D │ E │ F │ G │ H │ I │ J │
// ├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
// │ 1 │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │
// └───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘

HEX_DIGITS()

Back to top

A sequence of the digits from 0 through 9 and A through F.

Example:

=HEX_DIGITS()
// ┌───┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐
// │   │ A   │ B   │ C   │ D   │ E   │ F   │ G   │ H   │ I   │ J   │ K   │ L   │ M   │ N   │ O   │ P   │ Q   │ R   │ S   │ T   │ U   │ V   │
// ├───┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
// │ 1 │ "0" │ "1" │ "2" │ "3" │ "4" │ "5" │ "6" │ "7" │ "8" │ "9" │ "a" │ "b" │ "c" │ "d" │ "e" │ "f" │ "A" │ "B" │ "C" │ "D" │ "E" │ "F" │
// └───┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘

MATRIX(rows: NUMBER, cols: NUMBER, fill: T)

Back to top

Create a matrix of size rows x cols. With an optional default value.

  • rows: The number of rows in the matrix.
  • cols: The number of columns in the matrix.
  • fill: The default value for each cell in the matrix.

Example:

=MATRIX(4, 5, 3)
// ┌───┬───┬───┬───┬───┬───┐
// │   │ A │ B │ C │ D │ E │
// ├───┼───┼───┼───┼───┼───┤
// │ 1 │ 3 │ 3 │ 3 │ 3 │ 3 │
// ├───┼───┼───┼───┼───┼───┤
// │ 2 │ 3 │ 3 │ 3 │ 3 │ 3 │
// ├───┼───┼───┼───┼───┼───┤
// │ 3 │ 3 │ 3 │ 3 │ 3 │ 3 │
// ├───┼───┼───┼───┼───┼───┤
// │ 4 │ 3 │ 3 │ 3 │ 3 │ 3 │
// └───┴───┴───┴───┴───┴───┘

OCT_DIGITS()

Back to top

A sequence of the digits from 0 through 7

Example:

=OCT_DIGITS()
// ┌───┬───┬───┬───┬───┬───┬───┬───┬───┐
// │   │ A │ B │ C │ D │ E │ F │ G │ H │
// ├───┼───┼───┼───┼───┼───┼───┼───┼───┤
// │ 1 │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │
// └───┴───┴───┴───┴───┴───┴───┴───┴───┘

RANGE(min: NUMBER, max?: NUMBER)

Back to top

Generate a sequence of numbers from start to end.

Examples:

=RANGE(3, 7)
// ┌───┬───┬───┬───┬───┐
// │   │ A │ B │ C │ D │
// ├───┼───┼───┼───┼───┤
// │ 1 │ 3 │ 4 │ 5 │ 6 │
// └───┴───┴───┴───┴───┘
=RANGE(10)
// ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
// │   │ A │ B │ C │ D │ E │ F │ G │ H │ I │ J │
// ├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
// │ 1 │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │
// └───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘

TRANSPOSE(value: T | T[] | T[][])

Back to top

Transpose an array.

  • value: The array to transpose.

Example:

// Dependencies:
=DIGITS()
// ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
// │   │ A │ B │ C │ D │ E │ F │ G │ H │ I │ J │
// ├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
// │ 1 │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │
// └───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘

=TRANSPOSE(DIGITS())
// ┌────┬───┐
// │    │ A │
// ├────┼───┤
// │ 1  │ 0 │
// ├────┼───┤
// │ 2  │ 1 │
// ├────┼───┤
// │ 3  │ 2 │
// ├────┼───┤
// │ 4  │ 3 │
// ├────┼───┤
// │ 5  │ 4 │
// ├────┼───┤
// │ 6  │ 5 │
// ├────┼───┤
// │ 7  │ 6 │
// ├────┼───┤
// │ 8  │ 7 │
// ├────┼───┤
// │ 9  │ 8 │
// ├────┼───┤
// │ 10 │ 9 │
// └────┴───┘

Statistical functions

AVERAGE(...values: T)

Back to top

Returns the average of NUMBER arguments.

  • values: The values to compare.

Example:

=AVERAGE(1, 3, 2, 5, 4)
// 3

COUNT(...values: T)

Back to top

Count the number of NUMBER arguments.

  • values: The values to count.

Example:

// Dependencies:
=TRUE() // TRUE

=COUNT(1, 2, TRUE(), "hello world", 3.2)
// 3

MAX(...values: T)

Back to top

Returns the largest NUMBER argument.

  • values: The values to compare.

Example:

=MAX(1, 3, 2, 5, 4)
// 5

MEDIAN(...values: T)

Back to top

Returns the median of NUMBER arguments.

  • values: The values to compare.

Example:

=MEDIAN(1, 3, 2, 5, 4)
// 3

MIN(...values: T)

Back to top

Returns the smallest NUMBER argument.

  • values: The values to compare.

Example:

=MIN(5, 4, 1, 2, 3)
// 1

MODE(...values: T)

Back to top

Returns the mode of NUMBER arguments.

  • values: The values to compare.

Example:

=MODE(3, 2, 1, 3, 3, 4, 5, 8, 9, 1)
// 3

Text functions

CHAR_CODE_AT(value: STRING, index: NUMBER)

Back to top

Get the character code at a specific index in a string.

  • value: The string to get the character code from.
  • index: The index of the character to get the character code from.

Examples:

=CHAR_CODE_AT("ABC", 0)
// 65
=CHAR_CODE_AT("ABC", 1)
// 66
=CHAR_CODE_AT("ABC", 2)
// 67

CONCAT(...values: T)

Back to top

Concatenates multiple strings together.

  • values: The strings to concatenate.

Example:

=CONCAT("hello", " ", "world")
// "hello world"

FIND_FIRST(haystack: STRING, ...needles: STRING)

Back to top

Returns the first needle found in the haystack.

  • haystack: The string to search in.
  • needles: The strings to search for.

Examples:

=FIND_FIRST("The quick brown fox jumps over the lazy dog", "fox", "dog")
// "fox"
=FIND_FIRST("The quick brown fox jumps over the lazy dog", "dog", "fox")
// "fox"
=FIND_FIRST("12345", "5", "4", "3", "2", "1")
// "1"
// Dependencies:
=INTO(DIGITS()) // ERROR: INTO() can only be used inside of a function
=DIGITS()
// ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
// │   │ A │ B │ C │ D │ E │ F │ G │ H │ I │ J │
// ├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
// │ 1 │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │
// └───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘

=FIND_FIRST("321", INTO(DIGITS()))
// "3"

FIND_FIRST_INDEX(haystack: STRING, ...needles: STRING)

Back to top

Returns the position of the first needle found in the haystack.

  • haystack: The string to search in.
  • needles: The strings to search for.

Examples:

=FIND_FIRST_INDEX("The quick brown fox jumps over the lazy dog", "fox", "dog")
// 16
=FIND_FIRST_INDEX("The quick brown fox jumps over the lazy dog", "dog", "fox")
// 16

FIND_LAST(haystack: STRING, ...needles: STRING)

Back to top

Returns the last needle found in the haystack.

  • haystack: The string to search in.
  • needles: The strings to search for.

Examples:

=FIND_LAST("The quick brown fox jumps over the lazy dog", "fox", "dog")
// "dog"
=FIND_LAST("The quick brown fox jumps over the lazy dog", "dog", "fox")
// "dog"

FIND_LAST_INDEX(haystack: STRING, ...needles: STRING)

Back to top

Returns the position of the last needle found in the haystack.

  • haystack: The string to search in.
  • needles: The strings to search for.

Examples:

=FIND_LAST_INDEX("The quick brown fox jumps over the lazy dog", "fox", "dog")
// 40
=FIND_LAST_INDEX("The quick brown fox jumps over the lazy dog", "dog", "fox")
// 40

JOIN(delimiter: STRING, ...values: T)

Back to top

Joins multiple strings together with a delimiter.

  • delimiter: The string to insert between each value.
  • values: The values to join.

Example:

// Dependencies:
=TRUE() // TRUE

=JOIN("-", 1, 2, "hello", "world", TRUE())
// "1-2-hello-world-TRUE"

LEN(value: STRING)

Back to top

Returns the length of a string.

  • value: The string to measure.

Example:

=LEN("Hello, World!")
// 13

LOWER(value: T)

Back to top

Converts a string to lowercase.

  • value: The string to convert.

Example:

=LOWER("Hello, World!")
// "hello, world!"

PAD_END(value: STRING | NUMBER, length: NUMBER, character: STRING | NUMBER)

Back to top

Pads the end of a string with a specified character.

  • value: The string to pad.
  • length: The length of the resulting string.
  • character: The character to pad with.

Example:

=PAD_END("123", 5, "0")
// "12300"

PAD_START(value: STRING | NUMBER, length: NUMBER, character: STRING | NUMBER)

Back to top

Pads the start of a string with a specified character.

  • value: The string to pad.
  • length: The length of the resulting string.
  • character: The character to pad with.

Example:

=PAD_START("123", 5, "0")
// "00123"

REPLACE_ALL(haystack: STRING, ...zip?: STRING | NUMBER)

Back to top

Replaces all occurrences of the needles with their replacements.

  • haystack: The string to search in.
  • zip: The strings to search for and their replacements.

Example:

=REPLACE_ALL("The quick brown fox jumps over the lazy dog", "fox", "cat", "dog", "wolf")
// "The quick brown cat jumps over the lazy wolf"

SPLIT(value: STRING, delimiter: STRING)

Back to top

Splits a string into an array of substrings separated by a delimiter.

  • value: The string to split.
  • delimiter: The string to split by.

Example:

=SPLIT("Hello World", " ")
// ┌───┬─────────┬─────────┐
// │   │ A       │ B       │
// ├───┼─────────┼─────────┤
// │ 1 │ "Hello" │ "World" │
// └───┴─────────┴─────────┘

TEXT_CHUNK(value: STRING, length: NUMBER)

Back to top

Chunk a string into smaller strings of a specified length.

  • value: The string to chunk.
  • length: The length of each chunk.

Example:

=TEXT_CHUNK("ABCDE", 2)
// ┌───┬──────┬──────┬─────┐
// │   │ A    │ B    │ C   │
// ├───┼──────┼──────┼─────┤
// │ 1 │ "AB" │ "CD" │ "E" │
// └───┴──────┴──────┴─────┘

TEXT_SLICE(value: STRING, start: NUMBER, end?: NUMBER)

Back to top

Returns a section of a string.

  • value: The string to slice.
  • start: The index to the beginning of the specified portion of the value.
  • end: The index to the end of the specified portion of the value. The substring includes the characters up to, but not including, the character indicated by end. If this value is not specified, the substring continues to the end of the value.

Examples:

=TEXT_SLICE("The quick brown fox jumps over the lazy dog", 0, 19)
// "The quick brown fox"
=TEXT_SLICE("The quick brown fox jumps over the lazy dog", 40)
// "dog"
=TEXT_SLICE("The quick brown fox jumps over the lazy dog", -3)
// "dog"
=TEXT_SLICE("The quick brown fox jumps over the lazy dog", 10, 19)
// "brown fox"

TEXT_WINDOW(value: STRING, length: NUMBER)

Back to top

Returns a sliding window of a specified length over a string.

  • value: The string to window.
  • length: The length of the window.

Example:

=TEXT_WINDOW("ABCDE", 2)
// ┌───┬──────┬──────┬──────┬──────┐
// │   │ A    │ B    │ C    │ D    │
// ├───┼──────┼──────┼──────┼──────┤
// │ 1 │ "AB" │ "BC" │ "CD" │ "DE" │
// └───┴──────┴──────┴──────┴──────┘

TRIM(value: STRING)

Back to top

Removes leading and trailing whitespace from a string.

  • value: The string to trim.

Example:

=TRIM("  Hello, World!  ")
// "Hello, World!"

UPPER(value: T)

Back to top

Converts a string to uppercase.

  • value: The string to convert.

Example:

=UPPER("Hello, World!")
// "HELLO, WORLD!"

Type functions

AS_BOOLEAN(value: T)

Back to top

Tries to convert a value to a boolean.

  • value: The value to convert.

Examples:

=AS_BOOLEAN(0)
// FALSE
=AS_BOOLEAN(1)
// TRUE
=AS_BOOLEAN("123")
// TRUE
=AS_BOOLEAN("0")
// TRUE
// Dependencies:
=TRUE() // TRUE

=AS_BOOLEAN(TRUE())
// TRUE
// Dependencies:
=FALSE() // FALSE

=AS_BOOLEAN(FALSE())
// FALSE
// Dependencies:
=NOW() // 2013-01-21 08:15:20

=AS_BOOLEAN(NOW())
// TRUE

AS_BOOLEANS(...values: T | T[] | T[][])

Back to top

Tries to convert a list of values to booleans.

  • values: The values to convert.

Example:

// Dependencies:
=TRUE() // TRUE
=FALSE() // FALSE
=NOW() // 2013-01-21 08:15:20

=AS_BOOLEANS(0, 1, "123", "0", TRUE(), FALSE(), NOW())
// ┌───┬───────┬──────┬──────┬──────┬──────┬───────┬──────┐
// │   │ A     │ B    │ C    │ D    │ E    │ F     │ G    │
// ├───┼───────┼──────┼──────┼──────┼──────┼───────┼──────┤
// │ 1 │ FALSE │ TRUE │ TRUE │ TRUE │ TRUE │ FALSE │ TRUE │
// └───┴───────┴──────┴──────┴──────┴──────┴───────┴──────┘

AS_CHAR(value: T)

Back to top

Tries to convert a numeric value to a character.

  • value: The number to convert.

Examples:

=AS_CHAR(65)
// "A"
=AS_CHAR(97)
// "a"

AS_NUMBER(value: T)

Back to top

Tries to convert a value to a number.

  • value: The value to convert.

Examples:

=AS_NUMBER(1)
// 1
=AS_NUMBER("123")
// 123
=AS_NUMBER("million")
// ERROR: AS_NUMBER() expects a number, got million
// Dependencies:
=TRUE() // TRUE

=AS_NUMBER(TRUE())
// 1
// Dependencies:
=FALSE() // FALSE

=AS_NUMBER(FALSE())
// 0
// Dependencies:
=NOW() // 2013-01-21 08:15:20

=AS_NUMBER(NOW())
// 1358752520000

AS_NUMBERS(...values: T | T[] | T[][])

Back to top

Tries to convert a list of values to numbers.

  • values: The values to convert.

Example:

// Dependencies:
=TRUE() // TRUE
=FALSE() // FALSE
=NOW() // 2013-01-21 08:15:20

=AS_NUMBERS(1, "123", "million", TRUE(), FALSE(), NOW())
// ┌───┬───┬─────┬───────┬───┬───┬───────────────┐
// │   │ A │ B   │ C     │ D │ E │ F             │
// ├───┼───┼─────┼───────┼───┼───┼───────────────┤
// │ 1 │ 1 │ 123 │ Error │ 1 │ 0 │ 1358752520000 │
// └───┴───┴─────┴───────┴───┴───┴───────────────┘
// 
// Errors:
// 
// · C1: AS_NUMBER() expects a number, got million

AS_STRING(value: T)

Back to top

Tries to convert a value to a string.

  • value: The value to convert.

Examples:

=AS_STRING(1)
// "1"
=AS_STRING("123")
// "123"
// Dependencies:
=TRUE() // TRUE

=AS_STRING(TRUE())
// "TRUE"
// Dependencies:
=FALSE() // FALSE

=AS_STRING(FALSE())
// "FALSE"
// Dependencies:
=NOW() // 2013-01-21 08:15:20

=AS_STRING(NOW())
// "2013-01-21 08:15:20"
// Dependencies:
=TIME() // 08:15:20

=AS_STRING(TIME())
// "08:15:20"

AS_STRINGS(...values: T | T[] | T[][])

Back to top

Tries to convert a list of values to strings.

  • values: The values to convert.

Example:

// Dependencies:
=TRUE() // TRUE
=FALSE() // FALSE
=NOW() // 2013-01-21 08:15:20
=TIME() // 08:15:20

=AS_STRINGS(1, "123", TRUE(), FALSE(), NOW(), TIME())
// ┌───┬─────┬───────┬────────┬─────────┬───────────────────────┬────────────┐
// │   │ A   │ B     │ C      │ D       │ E                     │ F          │
// ├───┼─────┼───────┼────────┼─────────┼───────────────────────┼────────────┤
// │ 1 │ "1" │ "123" │ "TRUE" │ "FALSE" │ "2013-01-21 08:15:20" │ "08:15:20" │
// └───┴─────┴───────┴────────┴─────────┴───────────────────────┴────────────┘

TYPE(value: T)

Back to top

Returns the type of a value.

  • value: The value to check.

Examples:

=TYPE(1)
// "number"
=TYPE("hello")
// "string"
// Dependencies:
=TRUE() // TRUE

=TYPE(TRUE())
// "boolean"
// Dependencies:
=NOW() // 2013-01-21 08:15:20

=TYPE(NOW())
// "datetime"
=TYPE(UNKNOWN_FUNCTION())
// "error"
=TYPE(B1)
// "empty"

Intrinsics

COL(cell?: CELL)

Back to top

Get the col number of a cell. If no cell is provided, the current cell will be used.

Examples:

=COL()
// 1
=COL(B3)
// 2

INHERIT_FORMULA(cell: CELL)

Back to top

Inherit a formula from another cell. References to other cells in the formula will be updated to be relative to the current cell.


INTO(value: T)

Back to top

Try to coerce a value into the type expected by the function argument's type.


MAP(list: T, lambda: Expression)

Back to top

Map a list of values using a lambda function.

Example:

// Dependencies:
=DIGITS()
// ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
// │   │ A │ B │ C │ D │ E │ F │ G │ H │ I │ J │
// ├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
// │ 1 │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │
// └───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘

=MAP(DIGITS(), VALUE() * 2)
// ┌───┬───┬───┬───┬───┬───┬────┬────┬────┬────┬────┐
// │   │ A │ B │ C │ D │ E │ F  │ G  │ H  │ I  │ J  │
// ├───┼───┼───┼───┼───┼───┼────┼────┼────┼────┼────┤
// │ 1 │ 0 │ 2 │ 4 │ 6 │ 8 │ 10 │ 12 │ 14 │ 16 │ 18 │
// └───┴───┴───┴───┴───┴───┴────┴────┴────┴────┴────┘

OFFSET_COL()

Back to top

Get the current col number of the value in the matrix. Only works inside of a MAP().


OFFSET_ROW()

Back to top

Get the current row number of the value in the matrix. Only works inside of a MAP().


ROW(cell?: CELL)

Back to top

Get the row number of a cell. If no cell is provided, the current cell will be used.

Examples:

=ROW()
// 1
=ROW(B3)
// 3

VALUE()

Back to top

Get the value of the current position in a matrix. Only works inside of a MAP().

About

I don't know why I created this

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors