Difference: SpreadSheetPlugin (4 vs. 5)

Revision 52004-03-16 - PeterThoeny

Line: 1 to 1
 

TWiki Spreadsheet Plugin

This Plugin adds speadsheet capabilities to TWiki topics. Formulas like %CALC{"$INT(7/3)"}% are evaluated at page view time. They can be placed in table cells and outside of tables.

Line: 43 to 43
 
"$COLUMN(offset)" The current column number with an optional offset
"$COUNTITEMS(list)" Counts individual items in a list. Example: %CALC{"$COUNTITEMS( $ABOVE() )"}% returns Closed: 1, Open: 2 assuming one cell above the current cell contains Closed and two cells contain Open
"$COUNTSTR(list, str)" 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 )"}%;
Deleted:
<
<
"$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 )"}%
"$EVAL(formula)" Evaluates a simple formula. Only addition, substraction, multiplication, division and modulus of numbers are supported. Any nesting is permitted. Example: %CALC{"$EVAL( (5 * 3) / 2 + 1.1 )"}% returns 8.6
"$EXACT(text1, text2)" Compares two text strings and returns 1 if they are exactly the same, or 0 if not. Example: %CALC{"$EXACT( foo, Foo )"}% returns 0; %CALC{"$EXACT( foo, $LOWER(Foo) )"}% returns 1
Line: 52 to 51
 
"$FORMATTIME( serial, text )" Convert a serialized date into a date string; the following variables in text are expanded: $second (seconds, 00..59); $minute (minutes, 00..59); $hour (hours, 00..23); $day (day of month, 01..31); $month (month, 01..12); $mon (month in text format, Jan..Dec); $year (4 digit year, 1999); $ye (2 digit year, 99), $wd (day number of the week, 1 for Sunday, 2 for Monday, etc), $wday (day of the week, Sun..Sat), $weekday (day of the week, Sunday..Saturday), $yearday (day of the year, 1..365, or 1..366 in leap years). Date is assumed to be server time; add GMT to indicate Greenwich time zone. See also $TIME(), $TODAY(), $FORMATGMTIME(), $TIMEDIFF(). Example: %CALC{"$FORMATTIME( 0, $year/$month/$day GMT )"}% returns 1970/01/01 GMT
"$FORMATGMTIME( serial, text )" Convert a serialized date into a date string in Greenwich time zone. Same variables expansion as in $FORMATTIME(). Example: %CALC{"$FORMATGMTIME( 1041379200, $day $mon $year )"}% returns 01 Jan 2003
"$GET(name)" Get the value of a previously set variable. Specify the variable name (alphanumeric characters and underscores). An empty string is returned if the variable does not exist. Use $SET() to set a variable first. 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 $SET(). Example: %CALC{"$GET( my_total )"}% returns the value of the my_total variable
Changed:
<
<
"$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:
%CALC{"$IF( $T(R1:C5) > 1000, Over Budget, OK )"}% returns Over Budget if value in R1:C5 is over 1000, OK if not
%CALC{"$IF( $EXACT($T(R1:C2),), empty, $T(R1:C2) )"}% returns the content of R1:C2 or empty if empty
%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)
>
>
"$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:
%CALC{"$IF( $T(R1:C5) > 1000, Over Budget, OK )"}% returns Over Budget if value in R1:C5 is over 1000, OK if not
%CALC{"$IF( $EXACT($T(R1:C2),), empty, $T(R1:C2) )"}% returns the content of R1:C2 or empty if empty
%CALC{"$SET(val, $IF( $T(R1:C2) == 0, zero, $T(R1:C2) ))"}% sets a variable conditionally
 
"$INT(formula)" Evaluates a simple formula and rounds the result down to the nearest integer. Example: %CALC{"$INT( 10 / 4 )"}% returns 2
"$LEFT()" The address range of cells to the left of the current cell
"$LENGTH(text)" The length in bytes of text. Example: %CALC{"$LENGTH(abcd)"}% returns 4
Changed:
<
<
"$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 |
>
>
"$LIST(range)" 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)" The lower case string of a text. Example: %CALC{"$LOWER( $T(R1:C5) )"}% returns the lower case string of the text in cell R1:C5
"$MAX(list)" The biggest value of a list or range of cells. Example: To find the biggest number to the left of the current cell, write: %CALC{"$MAX( $LEFT() )"}%
"$MEDIAN(list)" The median of a list or range of cells. Example: %CALC{"$MEDIAN(3, 9, 4, 5)"}% returns 4.5
Line: 76 to 80
 
"$ROW(offset)" The current row number with an offset. Example: To get the number of rows excluding table heading ( first row) and summary row (last row you are in), write: %CALC{"$ROW(-2)"}%
"$SEARCH(search_string, text, start_index)" Finds one text string search_string, within another text string text, and returns the number of the starting position of search_string, from the first character of text. This search a RegularExpression search; use $FIND() for non-regular expression searching. Starting position is 1; an empty string is returned if nothing is matched. Examples:
%CALC{"$SEARCH([uy], fluffy)"}% returns 3
%CALC{"$SEARCH([uy], fluffy, 3)"}% returns 6
%CALC{"$SEARCH([abc], fluffy,)"}% returns an empty string
"$SET(name, value)" 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
Added:
>
>
"$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
"$SUBSTITUTE(text, old, new, instance, option)" Substitutes new text for old text in a text string. instance specifies which occurance of old you want to replace. If you specify instance, only that instance is replaced. Otherwise, every occurance is changed to the new text. A literal search is performed by default; a RegularExpression search if the option is set to r. See also $REPLACE(), $TRANSLATE(). Examples:
%CALC{"$SUBSTITUTE(Good morning, morning, day)"}% returns Good day
%CALC{"$SUBSTITUTE(Q2-2002,2,3)"}% returns Q3-3003
%CALC{"$SUBSTITUTE(Q2-2002,2,3,3)"}% returns Q2-2003
%CALC{"$SUBSTITUTE(abc123def,[0-9],9,,r)"}% returns abc999def
"$SUM(list)" The sum of a list or range of cells. Example: To sum up column 5 excluding the title row, write: %CALC{"$SUM( R2:C5..R$ROW(-1):C5 )"}% in the last row; or simply %CALC{"$SUM( $ABOVE() )"}%
Line: 149 to 154
 

Plugin Info

Plugin Author: TWiki:Main/PeterThoeny
Changed:
<
<
Plugin Version: 08 Mar 2004
>
>
Plugin Version: 16 Mar 2004
 
Change History:
<-- specify latest version first -->
 
Added:
>
>
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()
06 Mar 2004: Added $AND(), $MOD(), $NOT(), $OR(), $PRODUCT(), $PROPER(), $PROPERSPACE(), $RAND(), $REPEAT(), $SIGN(), $VALUE(); added digits parameter to $ROUND(); renamed $MULT() to $PRODUCT(); $MULT() is deprecated and undocumented
27 Feb 2004: Added $COUNTUNIQUE()
Line: 180 to 186
  Related Topics: TWikiPreferences, TWikiPlugins
Changed:
<
<
-- TWiki:Main/PeterThoeny - 08 Mar 2004
>
>
-- TWiki:Main/PeterThoeny - 16 Mar 2004
 
This site is powered by the TWiki collaboration platformCopyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.SpreadSheetPlugin.