Simple Spreadsheet Function Reference
Simple Spreadsheet Manual
Cell References
= A1 // gives A1
= A2:A4 // gives array of A2,A3,A4
= [A2,A4] // gives array of A2,A4
Aggregate Functions
= sum(A2:A4) // gives A2+A3+A4
= sum(A2:B3) // gives A2+A3+B2+B3
= avg(2,3,4) // gives (2+3+4)/3 = 3
= min(2,3,4) // gives 2
= max(2,3,4) // gives 4
= count(A2:A4) // gives 3
Math Functions
Math.abs(a) // the absolute value of a
Math.acos(a) // arc cosine of a
Math.asin(a) // arc sine of a
Math.atan(a) // arc tangent of a
Math.atan2(a,b) // arc tangent of a/b
Math.ceil(a) // integer closest to a and not less than a
Math.cos(a) // cosine of a
Math.exp(a) // exponent of a
Math.floor(a) // integer closest to and not greater than a
Math.log(a) // log of a base e
Math.max(a,b) // the maximum of a and b
Math.min(a,b) // the minimum of a and b
Math.pow(a,b) // a to the power b
Math.random() // pseudorandom number in the range 0 to 1
Math.round(a) // integer closest to a
Math.sin(a) // sine of a
Math.sqrt(a) // square root of a
Math.tan(a) // tangent of a
Numbers
* conventional decimal numbers:
5 137 1.3
* decimal numbers in exponential form:
6.67e-11
-1.127e20
* octal numbers, for example:
01234 -077 0312
Positive octal numbers must begin with 0 (zero) and negative octal numbers must begin with -0.
* hexadecimal numbers, for example:
0xFF -0xCCFF 0xabcdef
Positive hexadecimals must begin with 0x and negative hexadecimals must begin with -0x.
Constants
Math.PI // pi = 3.14159265...
Math.E // e = 2.71828182...
Math.LOG2E // log of e base 2
Math.LOG10E // log of e base 10
Math.LN2 // log of 2 base e
Math.LN10 // log of 10 base e
Math.SQRT2 // square root of 2
Math.SQRT1_2 // square root of 1/2
Base conversion
= (32767).toString(16) // this gives "7fff"
= (255).toString(8) // this gives "377"
= (1295).toString(36) // this gives "zz"
= (127).toString(2) // this gives "1111111"
Arithmetic operations
Unary operations have one argument (in the following examples, the argument is a):
-a // change the sign of a
~a // bitwise NOT a
++a // add 1 to a (before using a)
a++ // add 1 to a (after using a)
--a // subtract 1 from a (before using a)
a-- // subtract 1 from a (after using a)
Binary operations operations have two arguments (in the following examples, the arguments are a and b):
a * b // multiply a by b
a / b // divide a by b
a % b // find the remainder of division of a by b
a + b // add a and b
a - b // subtract b from a
a & b // bitwise a AND b
a | b // bitwise a OR b
a ^ b // bitwise a XOR b
Shifts are the following operations:
a << b // shift a by b bits to the left
// (padding with zeros)
a >> b // shift a by b bits to the right
// (copying the sign bit)
a >>> b // shift a by b bits to the right
// (padding with zeros)
Random Numbers
= Math.random() // gives random, 0 to 1
If you need random floating-point numbers in the range from A to B, use this code:
= A + (B-A)*Math.random() // gives random, from A to B
Rounding
Math.round(10*X)/10; // round to tenths
Math.round(100*X)/100; // round to hundredths
Math.round(1000*X)/1000; // round to thousandths
Substrings
string.substring(start,end)
Here
string is the string from which you want to extract a substring.
start is the number specifying the position of the character at which the substring begins. (The character at start itself will be included in the substring.)
end is the number specifying the position of the character at which the substring ends. (The character at end will not be included in the substring.)
Note that the first character in the string corresponds to position 0, and the last character to position string.length-1.
Examples:
'Hello'.substring(0,2) // 'He'
'Hello'.substring(0,4) // 'Hell'
String Quoting
= 'I\'m not a JavaScript hacker.'
Conditions
= D2==10?"yes it is 10!":"other case"
Keyboard access keys [Alt+x]
* g = switch to goto field
* x = cut cell
* c = copy cell
* v = paste cell
* e = empty cell
Keyboard shortcuts
* enter = edit cell
* ctrl+x or shift+del = cut cell
* ctrl+c or ctrl+ins = copy cell
* ctrl+v or shift+ins = paste cell
* del = empty cell
* cursor up = go up
* cursor down = go down
* cursor left = go left
* cursor right = go right
* home = go to first cell in row or page up if already in first cell
* end = go to last cell in row or page down if already in last cell
* page up = go 10 rows down
* page down = go 10 rows up
// TODO add docu for functions:
charAt
charCodeAt
indexOf
lastIndexOf
split
match
replace
search
toLowerCase
toUpperCase
toFixed
// http://www.topxml.com/javascript/javascript_string_functions.asp#substring
// http://www.quirksmode.org/js/strings.html
// dates
// http://www.merlyn.demon.co.uk/js-dates.htm
// http://www.tizag.com/javascriptT/javascriptdate.php
css-styles
- nowrap
- color
- font, font-size, font-weight, font-family
- date functions
Sources:
- JavaScripter.net. Copyright © 1999-2000, Alexei Kourbatov