From: PeterThoeny Date: Tue, 16 Mar 2004 09:14:40 +0000 (+0000) Subject: none X-Git-Url: https://git.openafs.org/?p=openafs-wiki.git;a=commitdiff_plain;h=02f348393065c131f0f860d19217bde0fee27338;hp=0b6c0216fb8a57f24736da561dc279e4f79a40d9 none --- diff --git a/TWiki/SpreadSheetPlugin.mdwn b/TWiki/SpreadSheetPlugin.mdwn index 19b6385..a172e9a 100644 --- a/TWiki/SpreadSheetPlugin.mdwn +++ b/TWiki/SpreadSheetPlugin.mdwn @@ -104,10 +104,6 @@ The formula next to "Total" is `**%CALC\{"\$SUM( \$ABOVE() )"\}%**`. Counts the number of cells in a list equal to a given string (if str is specified), or counts the number of non empty cells in a list. Example: To count the number of non empty cells above the current cell, write `%CALC{"\$COUNTSTR( \$ABOVE() )"}%`; to count the number of cells equal to `DONE`, write `%CALC{"\$COUNTSTR( \$ABOVE(), DONE )"}%`; - `"\$COUNTUNIQUE(list)"` - Counts unique items in a list, separated by comma and/or space. Example: `%CALC{"\$COUNTUNIQUE( \$ABOVE() )"}%` returns `Alice: 2, Mike: 1, Tom: 2` assuming the cells above the current cell contain `Alice` and `Tom, Mike` and `Alice, Tom` - - `"\$DEF(list)"` Returns the first list item or cell reference that is not empty. Example: `%CALC{"\$DEF( R1:C1..R1:C3 )"}%` @@ -141,7 +137,7 @@ The formula next to "Total" is `**%CALC\{"\$SUM( \$ABOVE() )"\}%**`. `"\$IF(condition, value if true, value if 0)"` - Returns one value if a condition is met, and another value if not. The condition can be a number (where `0` means condition not met), or two numbers with a comparison operator `<` (less than), `<=` (less than or equal), `==` (equal), `!=` (not equal), `>=` (greater than or equal), `>` (greater than). Examples:%BR% `%CALC{"\$IF( \$T(R1:C5) > 1000, Over Budget, OK )"}%` returns `Over Budget` if value in R1:C5 is over 1000, `OK` if not%BR% `%CALC{"\$IF( \$EXACT(\$T(R1:C2),), empty, \$T(R1:C2) )"}%` returns the content of R1:C2 or `empty` if empty%BR% `%CALC{"\$SET(val, \$IF( \$T(R1:C2) == 0, zero, \$T(R1:C2) ))"}%` sets a variable conditionally (notice that you cannot set a variable conditionally inside an \$IF() since formulae in the "value if true" and "value if 0" are both evaluated before the condition is applied) + Returns one value if a condition is met, and another value if not. The condition can be a number (where `0` means condition not met), or two numbers with a comparison operator `<` (less than), `<=` (less than or equal), `==` (equal), `!=` (not equal), `>=` (greater than or equal), `>` (greater than). Examples:%BR% `%CALC{"\$IF( \$T(R1:C5) > 1000, Over Budget, OK )"}%` returns `Over Budget` if value in R1:C5 is over 1000, `OK` if not%BR% `%CALC{"\$IF( \$EXACT(\$T(R1:C2),), empty, \$T(R1:C2) )"}%` returns the content of R1:C2 or `empty` if empty%BR% `%CALC{"\$SET(val, \$IF( \$T(R1:C2) == 0, zero, \$T(R1:C2) ))"}%` sets a variable conditionally `"\$INT(formula)"` @@ -157,7 +153,27 @@ The formula next to "Total" is `**%CALC\{"\$SUM( \$ABOVE() )"\}%**`. `"\$LIST(range)"` - Converts the content of a range of cells into a flat list, delimited by comma. Example: `%CALC{"\$LIST( \$LEFT() )"}%` returns `Apples, Lemons, Oranges, Kiwis` assuming the cells to the left contain `| Apples | Lemons, Oranges | Kiwis |` + Converts the content of a range of cells into a flat list, delimited by comma. Cells containing commas are merged into the list. Example: `%CALC{"\$LIST( \$LEFT() )"}%` returns `Apples, Lemons, Oranges, Kiwis` assuming the cells to the left contain `| Apples | Lemons, Oranges | Kiwis |` + + + `"\$LISTMAP(formula, list)"` + Evaluate and update each element of a list. In the formla, `\$item` indicates the element, `\$index` the index of the list starting at 1. Example: `%CALC{"\$LISTMAP(\$index: \$EVAL(2 * \$item), 3, 5, 7, 11)"}%` returns `1: 6, 2: 10, 3: 14, 4: 22` + + + `"\$LISTREVERSE(list)"` + The opposite order of a list. Example: `%CALC{"\$LISTREVERSE(Apple, Orange, Apple, Kiwi)"}%` returns `Kiwi, Apple, Orange, Apple` + + + `"\$LISTSIZE(list)"` + The number of elements in a list. Example: `%CALC{"\$LISTSIZE(Apple, Orange, Apple, Kiwi)"}%` returns `4` + + + `"\$LISTSORT(list)"` + Sorts a list in ASCII order, or numerically if all elements are numeric. Example: `%CALC{"\$LISTSORT(Apple, Orange, Apple, Kiwi)"}%` returns `Apple, Apple, Kiwi, Orange` + + + `"\$LISTUNIQUE(list)"` + Removes all duplicates from a list. Example: `%CALC{"\$LISTUNIQUE(Apple, Orange, Apple, Kiwi)"}%` returns `Apple, Orange, Kiwi` `"\$LOWER(text)"` @@ -236,6 +252,10 @@ The formula next to "Total" is `**%CALC\{"\$SUM( \$ABOVE() )"\}%**`. Set a variable for later use. Specify the variable name (alphanumeric characters and underscores) and the value. The value may contain a formula; formulas are evaluated before the variable assignment. This function returns no output. Use `\$GET()` to retrieve variables. Unlike table ranges, variables live for the time of the page view and persist across tables, i.e. you can use it to summarize results across several tables. See also `\$GET()`. Example: `%CALC{"\$SET( my_total, \$SUM(\$ABOVE()) )"}%` sets the `my_total` variable to the sum of all table cells located above the current cell and returns an empty string + `"\$SETM(name, formula)"` + Updates an existing variable based on a formula. Specify the variable name (alphanumeric characters and underscores) and the formula. The formula must start with an operator to `+` (add), `-` (subtract), `*` (multiply), or `/` (divide) something to the variable. This function returns no output. Use `\$GET()` to retrieve variables. Example: `%CALC{"\$SETM( total, + \$SUM(\$LEFT()) )"}%` adds the sum of all table cells on the left to the `total` variable, and returns an empty string + + `"\$SIGN(num)"` The sign of a number. Returns -1 if `num` is negative, 0 if zero, or 1 if positive. Example: `%CALC{"\$SIGN(-12.5)"}%` returns `-1` @@ -399,13 +419,17 @@ Plugin settings are stored as preferences variables. To reference a plugin setti Plugin Version: - 08 Mar 2004 + 16 Mar 2004 Change History: Â  + 16 Mar 2004: + Added \$LISTMAP(), \$LISTREVERSE(), \$LISTSIZE(), \$LISTSORT(), \$LISTUNIQUE(), \$SETM(); retired \$COUNTUNIQUE() in favor of \$COUNTITEMS(\$LISTUNIQUE(); fixed evaluation order issue of \$IF(); fixed missing eval error messages suppressed since version 06 Mar 2004; redirect stderr messages to warning + + 08 Mar 2004: Added \$LIST() @@ -513,4 +537,4 @@ Plugin settings are stored as preferences variables. To reference a plugin setti **_Related Topics:_** [[TWikiPreferences]], [[TWikiPlugins]] --- TWiki:Main/PeterThoeny - 08 Mar 2004 +-- TWiki:Main/PeterThoeny - 16 Mar 2004