TWiki Spreadsheet Plugin<-- Contributions to this plugin are appreciated. Please update the plugin page at http://twiki.org/cgi-bin/view/Plugins/SpreadSheetPlugin or provide feedback at http://twiki.org/cgi-bin/view/Plugins/SpreadSheetPluginDev. If you are a TWiki contributor please update the plugin in the SVN repository. -->This plugin adds spreadsheet capabilities to TWiki topics. Formulae like %CALC{"$INT(7/3)"}% are evaluated at page view time. They can be placed in table cells and outside of tables. In other words, this plugin provides general formula evaluation capability, not just classic spreadsheet functions.
On this page:
Syntax RulesThe action of this plugin is triggered by the%CALC{"..."}% variable, which gets rendered according to the built-in function(s) found between the quotes.
Built-in FunctionsConventions for Syntax:
ABOVE( ) -- address range of cells above the current cell
ABS( num ) -- absolute value of a numberAND( list ) -- logical AND of a list
AVERAGE( list ) -- average of a list or a range of cells
BITXOR( text ) -- bit-wise XOR of text
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
CEILING( num ) -- return the smallest integer following a number
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CHAR( number ) -- ASCII character represented by number
CODE( text ) -- ASCII numeric value of character
COLUMN( offset ) -- current column number
COUNTITEMS( list ) -- count individual items in a list
COUNTSTR( list, str ) -- count the number of cells in a list equal to a given string
DEF( list ) -- find first non-empty list item or cell
EMPTY( text ) -- test for empty text
EVAL( formula ) -- evaluate a simple mathematical formula
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
EVEN( num ) -- test for even numberEXACT( text1, text2 ) -- compare two text strings
EXEC( formula ) -- execute a spreadsheet formula
EXISTS( topic ) -- check if topic exists
EXP( num ) -- exponent (e) raised to the power of a number
FIND( string, text, start ) -- find one string within another string
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
FLOOR( num ) -- return the largest integer preceding a number
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
FORMAT( type, precision, number ) -- format a number to a certain type and precision
FORMATGMTIME( serial, text ) -- convert a serialized date into a GMT date string
FORMATTIME( serial, text ) -- convert a serialized date into a date string
FORMATTIMEDIFF( unit, precision, time ) -- convert elapsed time to a string
GET( name ) -- get the value of a previously set variable
HEXDECODE( hexcode ) -- convert hexadecimal code to string
HEXENCODE( text ) -- encode text into hexadecimal code
IF( condition, value if true, value if 0 ) -- return a value based on a condition
INSERTSTRING( text, start, new ) -- insert a string into a text string
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | INT( formula ) -- evaluate formula and round down to nearest integer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | INT( formula ) -- evaluate formula and return integer truncated towards 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LEFT( ) -- address range of cells to the left of the current cell
LEFTSTRING( text, num ) -- extract characters at the beginning of a text string
LENGTH( text ) -- length of text in bytes
LIST( range ) -- convert content of a cell range into a list
LISTIF( condition, list ) -- remove elements from a list that do not meet a condition
LISTITEM( index, list ) -- get one element of a list
LISTJOIN( separator, list ) -- convert a list into a string
LISTMAP( formula, list ) -- evaluate and update each element of a list
LISTNONEMPTY( list ) -- remove all empty elements from a list
LISTRAND( list ) -- get one random element of a list
LISTREVERSE( list ) -- opposite order of a list
LISTSIZE( list ) -- number of elements in a list
LISTSHUFFLE( list ) -- shuffle element of a list in random order
LISTSORT( list ) -- sort a list
LISTTRUNCATE( size, list ) -- truncate list to size
LISTUNIQUE( list ) -- remove all duplicates from a list
LN( num ) -- natural logarithm of a number
LOG( num, base ) -- logarithm of a number to a given base
LOWER( text ) -- lower case string of a text
MAX( list ) - biggest value of a list or range of cells
MEDIAN( list ) -- median of a list or range of cells
MIN( list ) -- smallest value of a list or range of cells
MOD( num, divisor ) -- reminder after dividing | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ROW( offset ) -- current row number
SEARCH( string, text, start ) -- search a string within a text
SET( name, value ) -- set a variable for later use
SETIFEMPTY( name, value ) -- set a variable only if empty
SETM( name, formula ) -- update an existing variable based on a formula
SIGN( num ) -- sign of a number
SPLIT( separator, text ) -- split a string into a list
SQRT( num ) -- square root of a number
SUBSTITUTE( text, old, new, instance, option ) -- substitute text
SUBSTRING( text, start, num ) -- extract a substring out of a text string
SUM( list ) -- sum of a list or range of cells
SUMDAYS( list ) -- sum the days in a list or range of cells
SUMPRODUCT( list, list ) -- scalar product on ranges of cells
T( address ) -- content of a cell
TRANSLATE( text, from, to ) -- translate text from one set of characters to another
TIME( text ) -- convert a date string into a serialized date number
TIMEADD( serial, value, unit ) -- add a value to a serialized date
TIMEDIFF( serial_1, serial_2, unit ) -- time difference between two serialized dates
TODAY( ) -- serialized date of today at midnight GMT
TRIM( text ) -- trim spaces from text
UPPER( text ) -- upper case string of a text
VALUE( text ) -- convert text to number
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
WHILE( condition, do ) -- do something while a condition is true
WORKINGDAYS( serial_1, serial_2 ) -- working days between two serialized dates
XOR( list ) -- logical XOR of a list
FAQCan I use CALC in a formatted search?Specifically, how can I output some conditional text in a FormattedSearch? You need to escape the CALC so that it executes once per search hit. This can be done by escaping the% signs of %CALC{...}% with $percnt . For example, to execute $IF($EXACT($formfield(Tested), Yes), %PUBURL%/%SYSTEMWEB%/TWikiDocGraphics/choice-yes.gif, %PUBURL%/%SYSTEMWEB%/TWikiDocGraphics/choice-no.gif) in the format="" parameter, write this:
%SEARCH{ .... format="| $topic | $percntCALC{$IF($EXACT($formfield(Tested), Yes), %PUBURL%/%SYSTEMWEB%/TWikiDocGraphics/choice-yes.gif, %PUBURL%/%SYSTEMWEB%/TWikiDocGraphics/choice-no.gif)}$percnt |" }%
How can I easily repeat a formula in a table?To repeat the same formula in all cells of a table row define the formula once in a preferences setting and use that in the CALC. The preferences setting can be defined at the site level, web level or topic level, and may be hidden in HTML comments. Example:<!-- * Set MYFORMULA = $EVAL($SUBSTITUTE(...etc...)) --> | A | 1 | %CALC{%MYFORMULA%}% | | B | 2 | %CALC{%MYFORMULA%}% | | C | 3 | %CALC{%MYFORMULA%}% | CALC in Included TopicsBy default, CALCs in an included topic are evaluated with delay. The SKIPINCLUDE setting tells the plugin to evaluate the CALCs once all INCLUDEs are processed. This default behavior is chosen so that it is possible to compose a bigger table from several includes and do some spreadsheet calculation over the whole table.![]()
Bug Tracking Example
| Total: %CALC{"$ROW(-2)"}% \ | %CALC{"$COUNTITEMS( R2:C$COLUMN()..R$ROW(-1):C$COLUMN() )"}% | . \ | %CALC{"$COUNTITEMS( R2:C$COLUMN()..R$ROW(-1):C$COLUMN() )"}% \ | Total: %CALC{"$SUM( R2:C$COLUMN()..R$ROW(-1):C$COLUMN() )"}% |Above table is created manually. The table can be build dynamically with a formatted search, or by a plugin that pulls data from an external source, such as a bug tracking system. Plugin SettingsPlugin settings are stored as preferences variables. To reference a plugin setting write%<plugin>_<setting>% , i.e. %SPREADSHEETPLUGIN_SHORTDESCRIPTION%
Plugin Installation InstructionsNote: You do not need to install anything on the browser to use this plugin. Below installation instructions are for the administrator who needs to install this plugin on the TWiki server.
Plugin Info
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
TWiki Spreadsheet Plugin<-- Contributions to this plugin are appreciated. Please update the plugin page at http://twiki.org/cgi-bin/view/Plugins/SpreadSheetPlugin or provide feedback at http://twiki.org/cgi-bin/view/Plugins/SpreadSheetPluginDev. If you are a TWiki contributor please update the plugin in the SVN repository. -->This plugin adds spreadsheet capabilities to TWiki topics. Formulae like %CALC{"$INT(7/3)"}% are evaluated at page view time. They can be placed in table cells and outside of tables. In other words, this plugin provides general formula evaluation capability, not just classic spreadsheet functions.
On this page:
Syntax RulesThe action of this plugin is triggered by the%CALC{"..."}% variable, which gets rendered according to the built-in function(s) found between the quotes.
Built-in FunctionsConventions for Syntax:
ABOVE( ) -- address range of cells above the current cell
ABS( num ) -- absolute value of a numberAND( list ) -- logical AND of a list
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
AVERAGE( list ) -- average of a list or a range of cells | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
BITXOR( text ) -- bit-wise XOR of text
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CHAR( number ) -- ASCII character represented by number
CODE( text ) -- ASCII numeric value of character
COLUMN( offset ) -- current column number
COUNTITEMS( list ) -- count individual items in a list
COUNTSTR( list, str ) -- count the number of cells in a list equal to a given string
DEF( list ) -- find first non-empty list item or cell
EMPTY( text ) -- test for empty text
EVAL( formula ) -- evaluate a simple mathematical formula
EVEN( num ) -- test for even numberEXACT( text1, text2 ) -- compare two text strings
EXEC( formula ) -- execute a spreadsheet formula
EXISTS( topic ) -- check if topic exists
EXP( num ) -- exponent (e) raised to the power of a number
FIND( string, text, start ) -- find one string within another string
FORMAT( type, precision, number ) -- format a number to a certain type and precision
FORMATGMTIME( serial, text ) -- convert a serialized date into a GMT date string
FORMATTIME( serial, text ) -- convert a serialized date into a date string
FORMATTIMEDIFF( unit, precision, time ) -- convert elapsed time to a string
GET( name ) -- get the value of a previously set variable
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
HEXDECODE( hexcode ) -- convert hexadecimal code to string
HEXENCODE( text ) -- encode text into hexadecimal code
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
IF( condition, value if true, value if 0 ) -- return a value based on a condition
INSERTSTRING( text, start, new ) -- insert a string into a text string
INT( formula ) -- evaluate formula and round down to nearest integer
LEFT( ) -- address range of cells to the left of the current cell
LEFTSTRING( text, num ) -- extract characters at the beginning of a text string
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LENGTH( text ) -- length of text in bytes
LIST( range ) -- convert content of a cell range into a list
LISTIF( condition, list ) -- remove elements from a list that do not meet a condition
LISTITEM( index, list ) -- get one element of a list
LISTJOIN( separator, list ) -- convert a list into a string
LISTMAP( formula, list ) -- evaluate and update each element of a list
LISTNONEMPTY( list ) -- remove all empty elements from a list
LISTRAND( list ) -- get one random element of a list
LISTREVERSE( list ) -- opposite order of a list
LISTSIZE( list ) -- number of elements in a list
LISTSHUFFLE( list ) -- shuffle element of a list in random order
LISTSORT( list ) -- sort a list
LISTTRUNCATE( size, list ) -- truncate list to size
LISTUNIQUE( list ) -- remove all duplicates from a list
LN( num ) -- natural logarithm of a number
LOG( num, base ) -- logarithm of a number to a given base
LOWER( text ) -- lower case string of a text
MAX( list ) - biggest value of a list or range of cells
MEDIAN( list ) -- median of a list or range of cells
MIN( list ) -- smallest value of a list or range of cells
MOD( num, divisor ) -- reminder after dividing | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ODD( num ) -- test for odd numberOR( list ) -- logical OR of a list
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
PERCENTILE( num, list ) -- percentile of a list or range of cells
PI( ) -- mathematical constant Pi, 3.14159265358979
PRODUCT( list ) -- product of a list or range of cells
PROPER( text ) -- properly capitalize text
PROPERSPACE( text ) -- properly space out WikiWords
RAND( max ) -- random number
REPEAT( text, num ) -- repeat text a number of times
REPLACE( text, start, num, new ) -- replace part of a text string
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
RIGHT( ) -- address range of cells to the right of the current cell
RIGHTSTRING( text, num ) -- extract characters at the end of a text string
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ROUND( formula, digits ) -- round a number
ROW( offset ) -- current row number
SEARCH( string, text, start ) -- search a string within a text
SET( name, value ) -- set a variable for later use
SETIFEMPTY( name, value ) -- set a variable only if empty
SETM( name, formula ) -- update an existing variable based on a formula
SIGN( num ) -- sign of a number
SPLIT( separator, text ) -- split a string into a list
SQRT( num ) -- square root of a number
SUBSTITUTE( text, old, new, instance, option ) -- substitute text
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
SUBSTRING( text, start, num ) -- extract a substring out of a text string
SUM( list ) -- sum of a list or range of cells
SUMDAYS( list ) -- sum the days in a list or range of cells
SUMPRODUCT( list, list ) -- scalar product on ranges of cells
T( address ) -- content of a cell
TRANSLATE( text, from, to ) -- translate text from one set of characters to another
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
TIME( text ) -- convert a date string into a serialized date number
TIMEADD( serial, value, unit ) -- add a value to a serialized date
TIMEDIFF( serial_1, serial_2, unit ) -- time difference between two serialized dates
TODAY( ) -- serialized date of today at midnight GMT
TRIM( text ) -- trim spaces from text
UPPER( text ) -- upper case string of a text
VALUE( text ) -- convert text to number
WHILE( condition, do ) -- do something while a condition is true
WORKINGDAYS( serial_1, serial_2 ) -- working days between two serialized dates
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
XOR( list ) -- logical XOR of a list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
FAQCan I use CALC in a formatted search?Specifically, how can I output some conditional text in a FormattedSearch? You need to escape the CALC so that it executes once per search hit. This can be done by escaping the% signs of %CALC{...}% with $percnt . For example, to execute $IF($EXACT($formfield(Tested), Yes), %PUBURL%/%SYSTEMWEB%/TWikiDocGraphics/choice-yes.gif, %PUBURL%/%SYSTEMWEB%/TWikiDocGraphics/choice-no.gif) in the format="" parameter, write this:
%SEARCH{ .... format="| $topic | $percntCALC{$IF($EXACT($formfield(Tested), Yes), %PUBURL%/%SYSTEMWEB%/TWikiDocGraphics/choice-yes.gif, %PUBURL%/%SYSTEMWEB%/TWikiDocGraphics/choice-no.gif)}$percnt |" }%
How can I easily repeat a formula in a table?To repeat the same formula in all cells of a table row define the formula once in a preferences setting and use that in the CALC. The preferences setting can be defined at the site level, web level or topic level, and may be hidden in HTML comments. Example:<!-- * Set MYFORMULA = $EVAL($SUBSTITUTE(...etc...)) --> | A | 1 | %CALC{%MYFORMULA%}% | | B | 2 | %CALC{%MYFORMULA%}% | | C | 3 | %CALC{%MYFORMULA%}% | CALC in Included TopicsBy default, CALCs in an included topic are evaluated with delay. The SKIPINCLUDE setting tells the plugin to evaluate the CALCs once all INCLUDEs are processed. This default behavior is chosen so that it is possible to compose a bigger table from several includes and do some spreadsheet calculation over the whole table.![]()
Bug Tracking Example
| Total: %CALC{"$ROW(-2)"}% \ | %CALC{"$COUNTITEMS( R2:C$COLUMN()..R$ROW(-1):C$COLUMN() )"}% | . \ | %CALC{"$COUNTITEMS( R2:C$COLUMN()..R$ROW(-1):C$COLUMN() )"}% \ | Total: %CALC{"$SUM( R2:C$COLUMN()..R$ROW(-1):C$COLUMN() )"}% |Above table is created manually. The table can be build dynamically with a formatted search, or by a plugin that pulls data from an external source, such as a bug tracking system. Plugin SettingsPlugin settings are stored as preferences variables. To reference a plugin setting write%<plugin>_<setting>% , i.e. %SPREADSHEETPLUGIN_SHORTDESCRIPTION%
Plugin Installation InstructionsNote: You do not need to install anything on the browser to use this plugin. Below installation instructions are for the administrator who needs to install this plugin on the TWiki server.
Plugin Info | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
TWiki Spreadsheet Plugin<-- Contributions to this plugin are appreciated. Please update the plugin page at http://twiki.org/cgi-bin/view/Plugins/SpreadSheetPlugin or provide feedback at http://twiki.org/cgi-bin/view/Plugins/SpreadSheetPluginDev. If you are a TWiki contributor please update the plugin in the SVN repository. -->This plugin adds spreadsheet capabilities to TWiki topics. Formulae like %CALC{"$INT(7/3)"}% are evaluated at page view time. They can be placed in table cells and outside of tables. In other words, this plugin provides general formula evaluation capability, not just classic spreadsheet functions.
On this page:
Syntax RulesThe action of this plugin is triggered by the%CALC{"..."}% variable, which gets rendered according to the built-in function(s) found between the quotes.
Built-in FunctionsConventions for Syntax:
ABOVE( ) -- address range of cells above the current cell
ABS( num ) -- absolute value of a numberAND( list ) -- logical AND of a list
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
AVERAGE( list ) -- average of a list or a range of cells
CHAR( number ) -- ASCII character represented by number
CODE( text ) -- ASCII numeric value of character
COLUMN( offset ) -- current column number
COUNTITEMS( list ) -- count individual items in a list
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
COUNTSTR( list, str ) -- count the number of cells in a list equal to a given string
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
DEF( list ) -- find first non-empty list item or cell
EMPTY( text ) -- test for empty text
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
EVAL( formula ) -- evaluate a simple mathematical formula
EVEN( num ) -- test for even numberEXACT( text1, text2 ) -- compare two text strings
EXEC( formula ) -- execute a spreadsheet formula
EXISTS( topic ) -- check if topic exists
EXP( num ) -- exponent (e) raised to the power of a number
FIND( string, text, start ) -- find one string within another string
FORMAT( type, precision, number ) -- format a number to a certain type and precision
FORMATGMTIME( serial, text ) -- convert a serialized date into a GMT date string
FORMATTIME( serial, text ) -- convert a serialized date into a date string
FORMATTIMEDIFF( unit, precision, time ) -- convert elapsed time to a string
GET( name ) -- get the value of a previously set variable
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
IF( condition, value if true, value if 0 ) -- return a value based on a condition
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
INSERTSTRING( text, start, new ) -- insert a string into a text string
INT( formula ) -- evaluate formula and round down to nearest integer
LEFT( ) -- address range of cells to the left of the current cell
LEFTSTRING( text, num ) -- extract characters at the beginning of a text string
LENGTH( text ) -- length of text in bytes
LIST( range ) -- convert content of a cell range into a list
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LISTIF( condition, list ) -- remove elements from a list that do not meet a condition
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LISTITEM( index, list ) -- get one element of a list
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LISTJOIN( separator, list ) -- convert a list into a string | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LISTMAP( formula, list ) -- evaluate and update each element of a list
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
LISTNONEMPTY( list ) -- remove all empty elements from a list
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LISTRAND( list ) -- get one random element of a list
LISTREVERSE( list ) -- opposite order of a list
LISTSIZE( list ) -- number of elements in a list
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LISTSHUFFLE( list ) -- shuffle element of a list in random order
LISTSORT( list ) -- sort a list
LISTTRUNCATE( size, list ) -- truncate list to size
LISTUNIQUE( list ) -- remove all duplicates from a list
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LN( num ) -- natural logarithm of a number
LOG( num, base ) -- logarithm of a number to a given base
LOWER( text ) -- lower case string of a text
MAX( list ) - biggest value of a list or range of cells
MEDIAN( list ) -- median of a list or range of cells
MIN( list ) -- smallest value of a list or range of cells
MOD( num, divisor ) -- reminder after dividing | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ODD( num ) -- test for odd numberOR( list ) -- logical OR of a list
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
PERCENTILE( num, list ) -- percentile of a list or range of cells
PI( ) -- mathematical constant Pi, 3.14159265358979
PRODUCT( list ) -- product of a list or range of cells
PROPER( text ) -- properly capitalize text
PROPERSPACE( text ) -- properly space out WikiWords
RAND( max ) -- random number
REPEAT( text, num ) -- repeat text a number of times
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
REPLACE( text, start, num, new ) -- replace part of a text string
RIGHT( ) -- address range of cells to the right of the current cell
RIGHTSTRING( text, num ) -- extract characters at the end of a text string
ROUND( formula, digits ) -- round a number
ROW( offset ) -- current row number
SEARCH( string, text, start ) -- search a string within a text
SET( name, value ) -- set a variable for later use
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
SETIFEMPTY( name, value ) -- set a variable only if empty
SETM( name, formula ) -- update an existing variable based on a formula
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
SIGN( num ) -- sign of a number | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
SPLIT( separator, text ) -- split a string into a list
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
SQRT( num ) -- square root of a number
SUBSTITUTE( text, old, new, instance, option ) -- substitute text
SUBSTRING( text, start, num ) -- extract a substring out of a text string
SUM( list ) -- sum of a list or range of cells
SUMDAYS( list ) -- sum the days in a list or range of cells
SUMPRODUCT( list, list ) -- scalar product on ranges of cells
T( address ) -- content of a cell
TRANSLATE( text, from, to ) -- translate text from one set of characters to another
TIME( text ) -- convert a date string into a serialized date number
TIMEADD( serial, value, unit ) -- add a value to a serialized date
TIMEDIFF( serial_1, serial_2, unit ) -- time difference between two serialized dates
TODAY( ) -- serialized date of today at midnight GMT
TRIM( text ) -- trim spaces from text
UPPER( text ) -- upper case string of a text
VALUE( text ) -- convert text to number | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
WHILE( condition, do ) -- do something while a condition is true
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
WORKINGDAYS( serial_1, serial_2 ) -- working days between two serialized dates
FAQCan I use CALC in a formatted search?Specifically, how can I output some conditional text in a FormattedSearch? You need to escape the CALC so that it executes once per search hit. This can be done by escaping the% signs of %CALC{...}% with $percnt . For example, to execute $IF($EXACT($formfield(Tested), Yes), %PUBURL%/%SYSTEMWEB%/TWikiDocGraphics/choice-yes.gif, %PUBURL%/%SYSTEMWEB%/TWikiDocGraphics/choice-no.gif) in the format="" parameter, write this:
%SEARCH{ .... format="| $topic | $percntCALC{$IF($EXACT($formfield(Tested), Yes), %PUBURL%/%SYSTEMWEB%/TWikiDocGraphics/choice-yes.gif, %PUBURL%/%SYSTEMWEB%/TWikiDocGraphics/choice-no.gif)}$percnt |" }%
How can I easily repeat a formula in a table?To repeat the same formula in all cells of a table row define the formula once in a preferences setting and use that in the CALC. The preferences setting can be defined at the site level, web level or topic level, and may be hidden in HTML comments. Example:<!-- * Set MYFORMULA = $EVAL($SUBSTITUTE(...etc...)) --> | A | 1 | %CALC{%MYFORMULA%}% | | B | 2 | %CALC{%MYFORMULA%}% | | C | 3 | %CALC{%MYFORMULA%}% | CALC in Included TopicsBy default, CALCs in an included topic are evaluated with delay. The SKIPINCLUDE setting tells the plugin to evaluate the CALCs once all INCLUDEs are processed. This default behavior is chosen so that it is possible to compose a bigger table from several includes and do some spreadsheet calculation over the whole table.![]()
Bug Tracking Example
| Total: %CALC{"$ROW(-2)"}% \ | %CALC{"$COUNTITEMS( R2:C$COLUMN()..R$ROW(-1):C$COLUMN() )"}% | . \ | %CALC{"$COUNTITEMS( R2:C$COLUMN()..R$ROW(-1):C$COLUMN() )"}% \ | Total: %CALC{"$SUM( R2:C$COLUMN()..R$ROW(-1):C$COLUMN() )"}% |Above table is created manually. The table can be build dynamically with a formatted search, or by a plugin that pulls data from an external source, such as a bug tracking system. Plugin SettingsPlugin settings are stored as preferences variables. To reference a plugin setting write%<plugin>_<setting>% , i.e. %SPREADSHEETPLUGIN_SHORTDESCRIPTION%
Plugin Installation InstructionsNote: You do not need to install anything on the browser to use this plugin. Below installation instructions are for the administrator who needs to install this plugin on the TWiki server.
Plugin Info
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
TWiki Spreadsheet Plugin<-- Contributions to this plugin are appreciated. Please update the plugin page at http://twiki.org/cgi-bin/view/Plugins/SpreadSheetPlugin or provide feedback at http://twiki.org/cgi-bin/view/Plugins/SpreadSheetPluginDev. If you are a TWiki contributor please update the plugin in the SVN repository. -->This plugin adds spreadsheet capabilities to TWiki topics. Formulae like %CALC{"$INT(7/3)"}% are evaluated at page view time. They can be placed in table cells and outside of tables. In other words, this plugin provides general formula evaluation capability, not just classic spreadsheet functions.
On this page:
Syntax RulesThe action of this plugin is triggered by the%CALC{"..."}% variable, which gets rendered according to the built-in function(s) found between the quotes.
Built-in FunctionsConventions for Syntax:
ABOVE( ) -- address range of cells above the current cell
ABS( num ) -- absolute value of a numberAND( list ) -- logical AND of a listAVERAGE( list ) -- average of a list or a range of cells
CHAR( number ) -- ASCII character represented by number
CODE( text ) -- ASCII numeric value of character
COLUMN( offset ) -- current column number
COUNTITEMS( list ) -- count individual items in a list
COUNTSTR( list, str ) -- count the number of cells in a list equal to a given string
DEF( list ) -- find first non-empty list item or cell
EMPTY( text ) -- test for empty text
EVAL( formula ) -- evaluate a simple mathematical formula
EVEN( num ) -- test for even numberEXACT( text1, text2 ) -- compare two text strings
EXEC( formula ) -- execute a spreadsheet formula
EXISTS( topic ) -- check if topic exists
EXP( num ) -- exponent (e) raised to the power of a number
FIND( string, text, start ) -- find one string within another string
FORMAT( type, precision, number ) -- format a number to a certain type and precision
FORMATGMTIME( serial, text ) -- convert a serialized date into a GMT date string
FORMATTIME( serial, text ) -- convert a serialized date into a date string | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
FORMATTIMEDIFF( unit, precision, time ) -- convert elapsed time to a string
GET( name ) -- get the value of a previously set variable
IF( condition, value if true, value if 0 ) -- return a value based on a condition
INSERTSTRING( text, start, new ) -- insert a string into a text string
INT( formula ) -- evaluate formula and round down to nearest integer
LEFT( ) -- address range of cells to the left of the current cell
LEFTSTRING( text, num ) -- extract characters at the beginning of a text string
LENGTH( text ) -- length of text in bytes
LIST( range ) -- convert content of a cell range into a list
LISTIF( condition, list ) -- remove elements from a list that do not meet a condition
LISTITEM( index, list ) -- get one element of a list
LISTJOIN( separator, list ) -- convert a list into a string | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LISTMAP( formula, list ) -- evaluate and update each element of a list
LISTRAND( list ) -- get one random element of a list
LISTREVERSE( list ) -- opposite order of a list
LISTSIZE( list ) -- number of elements in a list
LISTSHUFFLE( list ) -- shuffle element of a list in random order
LISTSORT( list ) -- sort a list
LISTTRUNCATE( size, list ) -- truncate list to size
LISTUNIQUE( list ) -- remove all duplicates from a list
LN( num ) -- natural logarithm of a number
LOG( num, base ) -- logarithm of a number to a given base
LOWER( text ) -- lower case string of a text
MAX( list ) - biggest value of a list or range of cells
MEDIAN( list ) -- median of a list or range of cells
MIN( list ) -- smallest value of a list or range of cells
MOD( num, divisor ) -- reminder after dividing | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
TIME( text ) -- convert a date string into a serialized date number
TIMEADD( serial, value, unit ) -- add a value to a serialized date
TIMEDIFF( serial_1, serial_2, unit ) -- time difference between two serialized dates
TODAY( ) -- serialized date of today at midnight GMT
TRIM( text ) -- trim spaces from text
UPPER( text ) -- upper case string of a text
VALUE( text ) -- convert text to number
WORKINGDAYS( serial_1, serial_2 ) -- working days between two serialized dates
FAQCan I use CALC in a formatted search?Specifically, how can I output some conditional text in a FormattedSearch? You need to escape the CALC so that it executes once per search hit. This can be done by escaping the% signs of %CALC{...}% with $percnt . For example, to execute $IF($EXACT($formfield(Tested), Yes), %PUBURL%/%SYSTEMWEB%/TWikiDocGraphics/choice-yes.gif, %PUBURL%/%SYSTEMWEB%/TWikiDocGraphics/choice-no.gif) in the format="" parameter, write this:
%SEARCH{ .... format="| $topic | $percntCALC{$IF($EXACT($formfield(Tested), Yes), %PUBURL%/%SYSTEMWEB%/TWikiDocGraphics/choice-yes.gif, %PUBURL%/%SYSTEMWEB%/TWikiDocGraphics/choice-no.gif)}$percnt |" }%
How can I easily repeat a formula in a table?To repeat the same formula in all cells of a table row define the formula once in a preferences setting and use that in the CALC. The preferences setting can be defined at the site level, web level or topic level, and may be hidden in HTML comments. Example:<!-- * Set MYFORMULA = $EVAL($SUBSTITUTE(...etc...)) --> | A | 1 | %CALC{%MYFORMULA%}% | | B | 2 | %CALC{%MYFORMULA%}% | | C | 3 | %CALC{%MYFORMULA%}% | | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
CALC in Included TopicsBy default, CALCs in an included topic are evaluated with delay. The SKIPINCLUDE setting tells the plugin to evaluate the CALCs once all INCLUDEs are processed. This default behavior is chosen so that it is possible to compose a bigger table from several includes and do some spreadsheet calculation over the whole table.![]()
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Bug Tracking Example
| Total: %CALC{"$ROW(-2)"}% \ | %CALC{"$COUNTITEMS( R2:C$COLUMN()..R$ROW(-1):C$COLUMN() )"}% | . \ | %CALC{"$COUNTITEMS( R2:C$COLUMN()..R$ROW(-1):C$COLUMN() )"}% \ | Total: %CALC{"$SUM( R2:C$COLUMN()..R$ROW(-1):C$COLUMN() )"}% |Above table is created manually. The table can be build dynamically with a formatted search, or by a plugin that pulls data from an external source, such as a bug tracking system. Plugin SettingsPlugin settings are stored as preferences variables. To reference a plugin setting write%<plugin>_<setting>% , i.e. %SPREADSHEETPLUGIN_SHORTDESCRIPTION%
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Deleted: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Plugin Installation InstructionsNote: You do not need to install anything on the browser to use this plugin. Below installation instructions are for the administrator who needs to install this plugin on the TWiki server.
Plugin Info
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | TWiki Spreadsheet Plugin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Deleted: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | TWiki Spreadsheet Plugin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This plugin adds spreadsheet capabilities to TWiki topics. Formulae like %CALC{"$INT(7/3)"}% are evaluated at page view time. They can be placed in table cells and outside of tables. In other words, this plugin provides general formula evaluation capability, not just classic spreadsheet functions.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | Formula: %CALC{" TWikiGuest)" />"}% | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | Formula: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | %CALC{" TWikiGuest)" class="twikiInputField" />"}%
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Result: TWiki Guest | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Deleted: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
On this page:
Syntax RulesThe action of this plugin is triggered by the%CALC{"..."}% variable, which gets rendered according to the built-in function(s) found between the quotes.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Deleted: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Built-in FunctionsConventions for Syntax:
ABOVE( ) -- address range of cells above the current cell
ABS( num ) -- absolute value of a numberAND( list ) -- logical AND of a listAVERAGE( list ) -- average of a list or a range of cells
CHAR( number ) -- ASCII character represented by number
CODE( text ) -- ASCII numeric value of character
COLUMN( offset ) -- current column number
COUNTITEMS( list ) -- count individual items in a list
COUNTSTR( list, str ) -- count the number of cells in a list equal to a given string
DEF( list ) -- find first non-empty list item or cell
EMPTY( text ) -- test for empty text
EVAL( formula ) -- evaluate a simple mathematical formula
EVEN( num ) -- test for even numberEXACT( text1, text2 ) -- compare two text strings
EXEC( formula ) -- execute a spreadsheet formula
EXISTS( topic ) -- check if topic exists
EXP( num ) -- exponent (e) raised to the power of a number
FIND( string, text, start ) -- find one string within another string
FORMAT( type, precision, number ) -- format a number to a certain type and precision
FORMATGMTIME( serial, text ) -- convert a serialized date into a GMT date string
FORMATTIME( serial, text ) -- convert a serialized date into a date string
FORMATTIMEDIFF( unit, precision, time ) -- convert elapsed time to a string
GET( name ) -- get the value of a previously set variable
IF( condition, value if true, value if 0 ) -- return a value based on a condition
INSERTSTRING( text, start, new ) -- insert a string into a text string
INT( formula ) -- evaluate formula and round down to nearest integer
LEFT( ) -- address range of cells to the left of the current cell
LEFTSTRING( text, num ) -- extract characters at the beginning of a text string
LENGTH( text ) -- length of text in bytes
LIST( range ) -- convert content of a cell range into a list
LISTIF( condition, list ) -- remove elements from a list that do not meet a condition
LISTITEM( index, list ) -- get one element of a list
LISTJOIN( separator, list ) -- convert a list into a string
LISTMAP( formula, list ) -- evaluate and update each element of a list
LISTRAND( list ) -- get one random element of a list
LISTREVERSE( list ) -- opposite order of a list
LISTSIZE( list ) -- number of elements in a list
LISTSHUFFLE( list ) -- shuffle element of a list in random order
LISTSORT( list ) -- sort a list
LISTTRUNCATE( size, list ) -- truncate list to size
LISTUNIQUE( list ) -- remove all duplicates from a list
LN( num ) -- natural logarithm of a number
LOG( num, base ) -- logarithm of a number to a given base
LOWER( text ) -- lower case string of a text
MAX( list ) - biggest value of a list or range of cells
MEDIAN( list ) -- median of a list or range of cells
MIN( list ) -- smallest value of a list or range of cells
MOD( num, divisor ) -- reminder after dividing | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
NOT( num ) -- reverse logic of a number
ODD( num ) -- test for odd numberOR( list ) -- logical OR of a listPERCENTILE( num, list ) -- percentile of a list or range of cells
PI( ) -- mathematical constant Pi, 3.14159265358979
PRODUCT( list ) -- product of a list or range of cells
PROPER( text ) -- properly capitalize text
PROPERSPACE( text ) -- properly space out WikiWords
RAND( max ) -- random number
REPEAT( text, num ) -- repeat text a number of times
REPLACE( text, start, num, new ) -- replace part of a text string
RIGHT( ) -- address range of cells to the right of the current cell
RIGHTSTRING( text, num ) -- extract characters at the end of a text string
ROUND( formula, digits ) -- round a number
ROW( offset ) -- current row number
SEARCH( string, text, start ) -- search a string within a text
SET( name, value ) -- set a variable for later use
SETIFEMPTY( name, value ) -- set a variable only if empty
SETM( name, formula ) -- update an existing variable based on a formula
SIGN( num ) -- sign of a number
SQRT( num ) -- square root of a number
SUBSTITUTE( text, old, new, instance, option ) -- substitute text
SUBSTRING( text, start, num ) -- extract a substring out of a text string
SUM( list ) -- sum of a list or range of cells
SUMDAYS( list ) -- sum the days in a list or range of cells
SUMPRODUCT( list, list ) -- scalar product on ranges of cells
T( address ) -- content of a cell
TRANSLATE( text, from, to ) -- translate text from one set of characters to another
TIME( text ) -- convert a date string into a serialized date number | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
TIMEADD( serial, value, unit ) -- add a value to a serialized date
TIMEDIFF( serial_1, serial_2, unit ) -- time difference between two serialized dates
TODAY( ) -- serialized date of today at midnight GMT
TRIM( text ) -- trim spaces from text
UPPER( text ) -- upper case string of a text
VALUE( text ) -- convert text to number
WORKINGDAYS( serial_1, serial_2 ) -- working days between two serialized dates
FAQCan I use CALC in a formatted search?Specifically, how can I output some conditional text in a FormattedSearch? You need to escape the CALC so that it executes once per search hit. This can be done by escaping the% signs of %CALC{...}% with $percnt . For example, to execute $IF($EXACT($formfield(Tested), Yes), %PUBURL%/%SYSTEMWEB%/TWikiDocGraphics/choice-yes.gif, %PUBURL%/%SYSTEMWEB%/TWikiDocGraphics/choice-no.gif) in the format="" parameter, write this:
%SEARCH{ .... format="| $topic | $percntCALC{$IF($EXACT($formfield(Tested), Yes), %PUBURL%/%SYSTEMWEB%/TWikiDocGraphics/choice-yes.gif, %PUBURL%/%SYSTEMWEB%/TWikiDocGraphics/choice-no.gif)}$percnt |" }%
How can I easily repeat a formula in a table? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | To repeat the same formula in all cells of a table row define the formula once in a preferences setting and use that in the CALC. The preferences setting can be hidden in HTML comments. Example: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | To repeat the same formula in all cells of a table row define the formula once in a preferences setting and use that in the CALC. The preferences setting can be defined at the site level, web level or topic level, and may be hidden in HTML comments. Example: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<!-- * Set MYFORMULA = $EVAL($SUBSTITUTE(...etc...)) --> | A | 1 | %CALC{%MYFORMULA%}% | | B | 2 | %CALC{%MYFORMULA%}% | | C | 3 | %CALC{%MYFORMULA%}% | Bug Tracking Example
| Total: %CALC{"$ROW(-2)"}% \ | %CALC{"$COUNTITEMS( R2:C$COLUMN()..R$ROW(-1):C$COLUMN() )"}% | . \ | %CALC{"$COUNTITEMS( R2:C$COLUMN()..R$ROW(-1):C$COLUMN() )"}% \ | Total: %CALC{"$SUM( R2:C$COLUMN()..R$ROW(-1):C$COLUMN() )"}% | | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | Above table is created manually. Another plugin could build the table dynamically, e.g. by pulling data out of a bug tracking system. The Spreadsheet plugin can be used to display table data statistics. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | Above table is created manually. The table can be build dynamically with a formatted search, or by a plugin that pulls data from an external source, such as a bug tracking system. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Plugin SettingsPlugin settings are stored as preferences variables. To reference a plugin setting write%<plugin>_<setting>% , i.e. %SPREADSHEETPLUGIN_SHORTDESCRIPTION%
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Plugin Installation InstructionsNote: You do not need to install anything on the browser to use this plugin. Below installation instructions are for the administrator who needs to install this plugin on the TWiki server.
Plugin Info
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | Related Topics: TWikiPreferences, TWikiPlugins, VarCALC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | Related Topics: TWikiPreferences, TWikiPlugins, VarCALC, VarIF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Deleted: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | -- TWiki:Main/PeterThoeny - 26 Mar 2009 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<-- Contributions to this plugin are appreciated. Please update the plugin page at http://twiki.org/cgi-bin/view/Plugins/SpreadSheetPlugin or provide feedback at http://twiki.org/cgi-bin/view/Plugins/SpreadSheetPluginDev. If you are a TWiki contributor please update the plugin in the SVN repository. --> TWiki Spreadsheet PluginThis plugin adds spreadsheet capabilities to TWiki topics. Formulae like%CALC{"$INT(7/3)"}% are evaluated at page view time. They can be placed in table cells and outside of tables. In other words, this plugin provides general formula evaluation capability, not just classic spreadsheet functions.
On this page:
Syntax RulesThe action of this plugin is triggered by the%CALC{"..."}% variable, which gets rendered according to the built-in function(s) found between the quotes.
Built-in FunctionsConventions for Syntax:
ABOVE( ) -- address range of cells above the current cell
ABS( num ) -- absolute value of a numberAND( list ) -- logical AND of a listAVERAGE( list ) -- average of a list or a range of cells
CHAR( number ) -- ASCII character represented by number
CODE( text ) -- ASCII numeric value of character
COLUMN( offset ) -- current column number
COUNTITEMS( list ) -- count individual items in a list
COUNTSTR( list, str ) -- count the number of cells in a list equal to a given string
DEF( list ) -- find first non-empty list item or cell
EMPTY( text ) -- test for empty text
EVAL( formula ) -- evaluate a simple mathematical formula
EVEN( num ) -- test for even numberEXACT( text1, text2 ) -- compare two text strings
EXEC( formula ) -- execute a spreadsheet formula
EXISTS( topic ) -- check if topic exists
EXP( num ) -- exponent (e) raised to the power of a number
FIND( string, text, start ) -- find one string within another string
FORMAT( type, precision, number ) -- format a number to a certain type and precision
FORMATGMTIME( serial, text ) -- convert a serialized date into a GMT date string
FORMATTIME( serial, text ) -- convert a serialized date into a date string
FORMATTIMEDIFF( unit, precision, time ) -- convert elapsed time to a string
GET( name ) -- get the value of a previously set variable
IF( condition, value if true, value if 0 ) -- return a value based on a condition
INSERTSTRING( text, start, new ) -- insert a string into a text string
INT( formula ) -- evaluate formula and round down to nearest integer
LEFT( ) -- address range of cells to the left of the current cell
LEFTSTRING( text, num ) -- extract characters at the beginning of a text string
LENGTH( text ) -- length of text in bytes
LIST( range ) -- convert content of a cell range into a list
LISTIF( condition, list ) -- remove elements from a list that do not meet a condition
LISTITEM( index, list ) -- get one element of a list
LISTJOIN( separator, list ) -- convert a list into a string
LISTMAP( formula, list ) -- evaluate and update each element of a list
LISTRAND( list ) -- get one random element of a list
LISTREVERSE( list ) -- opposite order of a list
LISTSIZE( list ) -- number of elements in a list
LISTSHUFFLE( list ) -- shuffle element of a list in random order
LISTSORT( list ) -- sort a list
LISTTRUNCATE( size, list ) -- truncate list to size
LISTUNIQUE( list ) -- remove all duplicates from a list
LN( num ) -- natural logarithm of a number
LOG( num, base ) -- logarithm of a number to a given base
LOWER( text ) -- lower case string of a text
MAX( list ) - biggest value of a list or range of cells
MEDIAN( list ) -- median of a list or range of cells
MIN( list ) -- smallest value of a list or range of cells
MOD( num, divisor ) -- reminder after dividing |