none
[openafs-wiki.git] / TWiki / SpreadSheetPlugin.mdwn
1 # <a name="TWiki Spreadsheet Plugin"></a> TWiki Spreadsheet Plugin
2
3 This Plugin adds speadsheet capabilities to %WIKITOOLNAME% topics. Formulas like <code>**%CALC\{"$INT(7/3)"\}%**</code> are evaluated at page view time. They can be placed in table cells and outside of tables.
4
5 Example:
6
7 <table border="1" cellpadding="0" cellspacing="0">
8   <tr>
9     <th bgcolor="#99CCCC"><strong> Region: </strong></th>
10     <th bgcolor="#99CCCC"><strong> Sales: </strong></th>
11   </tr>
12   <tr>
13     <td> Northeast </td>
14     <td align="right"> 320 </td>
15   </tr>
16   <tr>
17     <td> Northwest </td>
18     <td align="right"> 580 </td>
19   </tr>
20   <tr>
21     <td> South </td>
22     <td align="right"> 240 </td>
23   </tr>
24   <tr>
25     <td> Europe </td>
26     <td align="right"> 610 </td>
27   </tr>
28   <tr>
29     <td> Asia </td>
30     <td align="right"> 220 </td>
31   </tr>
32   <tr>
33     <td> Total: </td>
34     <td align="right"> 1970 </td>
35   </tr>
36 </table>
37
38 The formula next to "Total" is <code>**%CALC\{"$SUM( $ABOVE() )"\}%**</code>. <br /> (you see the formula instead of the sum in case the Plugin is not installed or not enabled.)
39
40 ## <a name="Syntax Rules"></a> Syntax Rules
41
42 - The formula in the <code>**%CALC\{"formula"\}%**</code> variable can contain built-in functions
43 - Built-in function are of format <code>**$FUNCNAME(parameter)%**</code>
44 - Built-in functions may be nested, e.g. <code>**%CALC\{"$SUM( R2:C$COL(0)..R$ROW(-1):C$COL(0) )"\}%**</code>
45 - The function parameter can be text; a mathematical formula; a cell address; or a range of cell addresses
46 - Multiple parameters form a list; they are separated by a comma, followed by optional space, e.g. <code>**%CALC\{"$SUM( 3, 5, 7 )"\}%**</code>
47 - A table cell can be addressed as <code>**R1:C1**</code>. Table address matrix: <table border="1" cellpadding="0" cellspacing="0">
48   <tr>
49     <td><code><b>R1:C1</b></code></td>
50     <td><code><b>R1:C2</b></code></td>
51     <td><code><b>R1:C3</b></code></td>
52     <td><code><b>R1:C4</b></code></td>
53   </tr>
54   <tr>
55     <td><code><b>R2:C1</b></code></td>
56     <td><code><b>R2:C2</b></code></td>
57     <td><code><b>R2:C3</b></code></td>
58     <td><code><b>R2:C4</b></code></td>
59   </tr>
60 </table>
61 - A table cell range is defined by two cell addresses separated by <code>**".."**</code>, e.g. "row 1 through 20, column 3" is: <code>**R1:C3..R20:C3**</code>
62 - Lists can refer to values and/or table cell ranges, e.g. <code>**%CALC\{"$SUM( 3, 5, $T(R1:C7), R1:C11..R1:C15 )"\}%**</code>
63 - Formulae can only reference cells in the current or preceeding row of the current table; they may not reference cells below the current table row
64 - Formulae can also be placed outside of tables; they can reference cells in the preceeding table
65
66 ## <a name="Built-in Functions"></a> Built-in Functions
67
68 <table border="1" cellpadding="0" cellspacing="0">
69   <tr>
70     <th bgcolor="#99CCCC"><strong> Function </strong></th>
71     <th bgcolor="#99CCCC"><strong> Description </strong></th>
72   </tr>
73   <tr>
74     <td><code><b>"$ABOVE()"</b></code></td>
75     <td> The address range of cells above the current cell </td>
76   </tr>
77   <tr>
78     <td><code><b>"$AVERAGE(list)"</b></code></td>
79     <td> The average of the content of a range of cells. Example: To get the average of column 5 excluding the title row, write in the last row: <code><b>%CALC{"$AVERAGE( R2:C5..R$ROW(-1):C5 )"}%</b></code></td>
80   </tr>
81   <tr>
82     <td><code><b>"$CHAR(number)"</b></code></td>
83     <td> The ASCII character represented by number. Example: <code><b>%CALC{"$CHAR(97)"}%</b></code> returns <code><b>a</b></code></td>
84   </tr>
85   <tr>
86     <td><code><b>"$CODE(text)"</b></code></td>
87     <td> The ASCII numeric value of the first character in text. Example: <code><b>%CALC{"$CODE(abc)"}%</b></code> returns <code><b>97</b></code></td>
88   </tr>
89   <tr>
90     <td><code><b>"$COLUMN(offset)"</b></code></td>
91     <td> The current column number with an optional offset </td>
92   </tr>
93   <tr>
94     <td><code><b>"$COUNTITEMS(list)"</b></code></td>
95     <td> The count of individual items in a list. Example: To count the items of all cells above the current cell, write <code><b>%CALC{"$COUNTITEMS( $ABOVE() )"}%</b></code></td>
96   </tr>
97   <tr>
98     <td><code><b>"$COUNTSTR(list, str)"</b></code></td>
99     <td> 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 <code><b>%CALC{"$COUNTSTR( $ABOVE() )"}%</b></code>; to count the number of cells equal to <code><b>DONE</b></code>, write <code><b>%CALC{"$COUNTSTR( $ABOVE(), DONE )"}%</b></code>; </td>
100   </tr>
101   <tr>
102     <td><code><b>"$DEF(list)"</b></code></td>
103     <td> Returns the first list item or cell reference that is not empty. Example: <code><b>%CALC{"$DEF( R1:C1..R1:C3 )"}%</b></code></td>
104   </tr>
105   <tr>
106     <td><code><b>"$EVAL(formula)"</b></code></td>
107     <td> Evaluates a simple formula. Only addition, substraction, multiplication, division and modulus of numbers are supported. Any nesting is permitted. Example: <code><b>%CALC{"$EVAL( (5 * 3) / 2 + 1.1 )"}%</b></code> returns <code><b>8.6</b></code></td>
108   </tr>
109   <tr>
110     <td><code><b>"$EXACT(text1, text2)"</b></code></td>
111     <td> Compares two text strings and returns <code><b>1</b></code> if they are exactly the same, or <code><b>0</b></code> if not. Example: <code><b>%CALC{"$EXACT( foo, Foo )"}%</b></code> returns <code><b>0</b></code>; <code><b>%CALC{"$EXACT( foo, $LOWER(Foo) )"}%</b></code> returns <code><b>1</b></code></td>
112   </tr>
113   <tr>
114     <td><code><b>"$FIND(search_string, text, start_index)"</b></code></td>
115     <td> Finds one text string <code>search_string</code>, within another text string <code>text</code>, and returns the number of the starting position of <code>search_string</code>, from the first character of <code>text</code>. This search is case sensitive and is not a regular expression search; use <code>$SEARCH()</code> for regular expression searching. Starting position is 1; an empty string is returned if nothing is matched. Examples: %BR% <code><b>%CALC{"$FIND(f, fluffy)"}%</b></code> returns <code><b>1</b></code> %BR% <code><b>%CALC{"$FIND(f, fluffy, 2)"}%</b></code> returns <code><b>4</b></code> %BR% <code><b>%CALC{"$FIND(@, fluffy, 1)"}%</b></code> returns an empty string </td>
116   </tr>
117   <tr>
118     <td><code><b>"$FORMAT(type, prec, number)"</b></code></td>
119     <td> Formats a number to a certain type and precision. Types with examples:<br />  - <code><b>%CALC{"$FORMAT( COMMA, 2, 12345.6789 )"}%</b></code> returns <code><b>12,345.68</b></code><br />  - <code><b>%CALC{"$FORMAT( DOLLAR, 2, 12345.67 )"}%</b></code> returns <code><b>$12,345.68</b></code><br />  - <code><b>%CALC{"$FORMAT( NUMBER, 1, 12345.67 )"}%</b></code> returns <code><b>12345.7</b></code><br />  - <code><b>%CALC{"$FORMAT( PERCENT, 1, 0.1234567 )"}%</b></code> returns <code><b>12.3%</b></code></td>
120   </tr>
121   <tr>
122     <td><code><b>"$FORMATTIME( serial, text )"</b></code></td>
123     <td> Convert a serialized date into a date string; the following variables in text are expanded: <code>$second</code> (seconds, 00..59); <code>$minute</code> (minutes, 00..59); <code>$hour</code> (hours, 00..23); <code>$day</code> (day of month, 01..31); <code>$month</code> (month, 01..12); <code>$mon</code> (month in text format, Jan..Dec); <code>$year</code> (4 digit year, 1999); <code>$ye</code> (2 digit year, 99), <code>$wd</code> (day number of the week, 1 for Sunday, 2 for Monday, etc), <code>$wday</code> (day of the week, Sun..Sat), <code>$weekday</code> (day of the week, Sunday..Saturday), <code>$yearday</code> (day of the year, 1..365, or 1..366 in leap years). Date is assumed to be server time; add <code>GMT</code> to indicate Greenwich time zone. See also <code>$TIME()</code>, <code>$TODAY()</code>, <code>$FORMATGMTIME()</code>, <code>$TIMEDIFF()</code>. Example: <code><b>%CALC{"$FORMATTIME( 0, $year/$month/$day GMT )"}%</b></code> returns <code><b>1970/01/01 GMT</b></code></td>
124   </tr>
125   <tr>
126     <td><code><b>"$FORMATGMTIME( serial, text )"</b></code></td>
127     <td> Convert a serialized date into a date string in Greenwich time zone. Same variables expansion as in <code>$FORMATTIME()</code>. Example: <code><b>%CALC{"$FORMATGMTIME( 1041379200, $day $mon $year )"}%</b></code> returns <code><b>01 Jan 2003</b></code></td>
128   </tr>
129   <tr>
130     <td><code><b>"$GET(name)"</b></code></td>
131     <td> 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 <code>$SET()</code> 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 <code>$SET()</code>. Example: <code><b>%CALC{"$GET( my_total )"}%</b></code> returns the value of the <code>my_total</code> variable </td>
132   </tr>
133   <tr>
134     <td><code><b>"$IF(condition, value if true, value if 0)"</b></code></td>
135     <td> Returns one value if a condition is met, and another value if not. The condition can be a number (where <code><b>0</b></code> means condition not met), or two numbers with a comparison operator <code><b>&lt;</b></code> (less then), <code><b>&lt;=</b></code> (less then or equal), <code><b>==</b></code> (equal), <code><b>!=</b></code> (not equal), <code><b>&gt;=</b></code> (greater then or equal), <code><b>&gt;=</b></code> (greater then). Example: <code><b>%CALC{"$IF( $T(R1:C5) &gt; 1000, Over Budget, OK )"}%</b></code> returns <code><b>Over Budget</b></code> if value in R1:C5 is over 1000, <code><b>OK</b></code> if not </td>
136   </tr>
137   <tr>
138     <td><code><b>"$INT(formula)"</b></code></td>
139     <td> Evaluates a simple formula and rounds the result down to the nearest integer. Example: <code><b>%CALC{"$INT( 10 / 4 )"}%</b></code> returns <code><b>2</b></code></td>
140   </tr>
141   <tr>
142     <td><code><b>"$LEFT()"</b></code></td>
143     <td> The address range of cells to the left of the current cell </td>
144   </tr>
145   <tr>
146     <td><code><b>"$LENGTH(text)"</b></code></td>
147     <td> The length in bytes of text. Example: <code><b>%CALC{"$LENGTH(abcd)"}%</b></code> returns <code><b>4</b></code></td>
148   </tr>
149   <tr>
150     <td><code><b>"$LOWER(text)"</b></code></td>
151     <td> The lower case string of a text. Example: <code><b>%CALC{"$LOWER( $T(R1:C5) )"}%</b></code> returns the lower case string of the text in cell <code><b>R1:C5</b></code></td>
152   </tr>
153   <tr>
154     <td><code><b>"$MAX(list)"</b></code></td>
155     <td> The biggest value of a list or range of cells. Example: To find the biggest number to the left of the current cell, write: <code><b>%CALC{"$MAX( $LEFT() )"}%</b></code></td>
156   </tr>
157   <tr>
158     <td><code><b>"$MEDIAN(list)"</b></code></td>
159     <td> The median of a list or range of cells. Example: <code><b>%CALC{"$MEDIAN( 3, 9, 4, 5 )"}%</b></code> returns <code><b>4.5</b></code></td>
160   </tr>
161   <tr>
162     <td><code><b>"$MIN(list)"</b></code></td>
163     <td> The smallest value of a list or range of cells. Example: <code><b>%CALC{"$MIN( 15, 3, 28 )"}%</b></code> returns <code><b>3</b></code></td>
164   </tr>
165   <tr>
166     <td><code><b>"$MULT(list)"</b></code></td>
167     <td> The product of a list or range of cells. Example: to calculate the product of the cells to the left of the current one use <code><b>%CALC{"$MULT($LEFT())"}%</b></code></td>
168   </tr>
169   <tr>
170     <td><code><b>"$NOP(text)"</b></code></td>
171     <td> A no-operation. Allows one to defy the order of Plugin execution. For example, it will allow preprossing to be done before <code>%SEARCH{}%</code> is evaluated. Use <code>$per</code> to escape '%'. </td>
172   </tr>
173   <tr>
174     <td><code><b>"$REPLACE(text, start_num, num_chars, new_text)"</b></code></td>
175     <td> Replaces part of text string <code>text</code>, based on the starting position <code>start_num</code>, and the number of characters to replace <code>num_chars</code>. The characters are replaced with <code>new_text</code>. Starting position is 1; use a negative <code>start_num</code> to count from the end of the text. See also <code>$SUBSTITUTE()</code>, <code>$TRANSLATE()</code>. Example: %BR% <code><b>%CALC{"$REPLACE(abcdefghijk,6,5,*)"}%</b></code> returns <code><b>abcde*k</b></code></td>
176   </tr>
177   <tr>
178     <td><code><b>"$RIGHT()"</b></code></td>
179     <td> The address range of cells to the right of the current cell </td>
180   </tr>
181   <tr>
182     <td><code><b>"$ROUND(formula)"</b></code></td>
183     <td> Evaluates a simple formula and rounds the result up or down to the nearest integer. Example: <code><b>%CALC{"$INT( 10 / 6 )"}%</b></code> returns <code><b>2</b></code></td>
184   </tr>
185   <tr>
186     <td><code><b>"$ROW(offset)"</b></code></td>
187     <td> 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: <code><b>%CALC{"$ROW(-2)"}%</b></code></td>
188   </tr>
189   <tr>
190     <td><code><b>"$SEARCH(search_string, text, start_index)"</b></code></td>
191     <td> Finds one text string <code>search_string</code>, within another text string <code>text</code>, and returns the number of the starting position of <code>search_string</code>, from the first character of <code>text</code>. This search a [[TWiki/RegularExpression]] search; use <code>$FIND()</code> for non-regular expression searching. Starting position is 1; an empty string is returned if nothing is matched. Examples: %BR% <code><b>%CALC{"$SEARCH([uy], fluffy)"}%</b></code> returns <code><b>3</b></code> %BR% <code><b>%CALC{"$SEARCH([uy], fluffy, 3)"}%</b></code> returns <code><b>6</b></code> %BR% <code><b>%CALC{"$SEARCH([abc], fluffy,)"}%</b></code> returns an empty string </td>
192   </tr>
193   <tr>
194     <td><code><b>"$SET(name, value)"</b></code></td>
195     <td> 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 <code>$GET()</code> 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 <code>$GET()</code>. Example: <code><b>%CALC{"$SET( my_total, $SUM($ABOVE()) )"}%</b></code> sets the <code>my_total</code> variable to the sum of all table cells located above the current cell and returns an empty string </td>
196   </tr>
197   <tr>
198     <td><code><b>"$SUBSTITUTE(text, old, new, instance, option)"</b></code></td>
199     <td> Substitutes <code>new</code> text for <code>old</code> text in a <code>text</code> string. <code>instance</code> specifies which occurance of <code>old</code> you want to replace. If you specify <code>instance</code>, only that instance is replaced. Otherwise, every occurance is changed to the new text. A literal search is performed by default; a [[TWiki/RegularExpression]] search if the <code>option</code> is set to <code><b>r</b></code>. See also <code>$REPLACE()</code>, <code>$TRANSLATE()</code>. Examples: %BR% <code><b>%CALC{"$SUBSTITUTE(Good morning, morning, day)"}%</b></code> returns <code><b>Good day</b></code> %BR% <code><b>%CALC{"$SUBSTITUTE(Q2-2002,2,3)"}%</b></code> returns <code><b>Q3-3003</b></code> %BR% <code><b>%CALC{"$SUBSTITUTE(Q2-2002,2,3,3)"}%</b></code> returns <code><b>Q2-2003</b></code> %BR% <code><b>%CALC{"$SUBSTITUTE(abc123def,[0-9],9,,r)"}%</b></code> returns <code><b>abc999def</b></code></td>
200   </tr>
201   <tr>
202     <td><code><b>"$SUM(list)"</b></code></td>
203     <td> The sum of a list or range of cells. Example: To sum up column 5 excluding the title row, write: <code><b>%CALC{"$SUM( R2:C5..R$ROW(-1):C5 )"}%</b></code> in the last row; or simply <code><b>%CALC{"$SUM( $ABOVE() )"}%</b></code></td>
204   </tr>
205   <tr>
206     <td><code><b>"$SUMDAYS(list)"</b></code></td>
207     <td> The total number of days in a list or range of cells containing numbers of hours, days or weeks. The default unit is days; units are indicated by a <code><b>h</b></code>, <code><b>hours</b></code>, <code><b>d</b></code>, <code><b>days</b></code>, <code><b>w</b></code>, <code><b>weeks</b></code> suffix. One week is assumed to have 5 working days, one day 8 hours. Example: <code><b>%CALC{"$SUMDAYS( 2w, 1, 2d, 4h )"}%</b></code> returns <code><b>13.5</b></code>, the evaluation of <code>(2*5 + 1 + 2 + 4/8)</code></td>
208   </tr>
209   <tr>
210     <td><code><b>"$SUMPRODUCT(list, list, ...)"</b></code></td>
211     <td> The scalar product on ranges of cells. Example: <code><b>%CALC{"$SUM( R2:C1..R4:C1, R2:C5..R4:C5 )"}%</b></code> evaluates and returns <code><b>($T(R2:C1) * $T(R2:C5) + $T(R3:C1) * $T(R3:C5) + $T(R4:C1) * $T(R4:C5))</b></code></td>
212   </tr>
213   <tr>
214     <td><code><b>"$T(address)"</b></code></td>
215     <td> The content of a cell. Example: <code><b>%CALC{"$T(R1:C5)"}%</b></code> returns the text in cell <code><b>R1:C5</b></code></td>
216   </tr>
217   <tr>
218     <td><code><b>"$TRANSLATE(text, from, to)"</b></code></td>
219     <td> Translate text from a set of characters to another set, one character by one. The <code>text</code> may contain commas; the last two comma separated parameters are required. For <code>from</code> and <code>to</code> parameters, you can write <code>$comma</code> to escape comma, <code>$sp</code> to escape space. See also <code>$REPLACE()</code>, <code>$SUBSTITUTE()</code>. Examples: %BR% <code><b>%CALC{"$TRANSLATE(boom,bm,cl)"}%</b></code> returns <code><b>cool</b></code> %BR% <code><b>%CALC{"$TRANSLATE(one, two,$comma,;)"}%</b></code> returns <code><b>one; two</b></code></td>
220   </tr>
221   <tr>
222     <td><code><b>"$TIME(text)"</b></code></td>
223     <td> Converts a date string into a serialized date number (seconds since the Epoch, e.g. midnight, 01 Jan 1970). Current time is taken if the date string is empty. Supported date formats: <code>31 Dec 2009</code>; <code>31 Dec 2009 GMT</code>; <code>31 Dec 09</code>; <code>31-Dec-2009</code>; <code>31/Dec/2009</code>; <code>2009/12/31</code>; <code>2009-12-31</code>; <code>2009/12/31</code>; <code>2009/12/31 23:59</code>; <code>2009/12/31 - 23:59</code>; <code>2009-12-31-23-59</code>; <code>2009/12/31 - 23:59:59</code>; <code>2009.12.31.23.59.59</code>. Date is assumed to be server time; add <code>GMT</code> to indicate Greenwich time zone. See also <code>$TODAY()</code>, <code>$FORMATTIME()</code>, <code>$FORMATGMTIME()</code>, <code>$TIMEDIFF()</code>. Example: <code><b>%CALC{"$TIME( 2003/10/14 GMT )"}%</b></code> returns <code><b>1066089600</b></code></td>
224   </tr>
225   <tr>
226     <td><code><b>"$TIMEADD( serial, value, unit )"</b></code></td>
227     <td> Add a value to a serialized date. The unit is seconds if not specified; unit can be <code>second</code>, <code>minute</code>, <code>hour</code>, <code>day</code>, <code>week</code>, <code>month</code>, <code>year</code>. Note: An approximation is used for month and year calculations. See also <code>$TIME()</code>, <code>$TIMEDIFF()</code>, <code>$TODAY()</code>, <code>$FORMATTIME()</code>. Example: <code><b>%CALC{"$TIMEADD( $TIME(), 2, week )"}%</b></code> returns the serialized date two weeks from now </td>
228   </tr>
229   <tr>
230     <td><code><b>"$TIMEDIFF( serial_1, serial_2, unit )"</b></code></td>
231     <td> Time difference between two serialized dates. The unit is seconds if not specified; unit can be specified as in <code>$TIMEADD()</code>. Note: An approximation is used for month and year calculations. Use <code>$FORMAT()</code> or <code>$INT()</code> to format real numbers. See also <code>$TIME()</code>, <code>$TIMEADD()</code>, <code>$TODAY()</code>, <code>$FORMATTIME()</code>. Example: <code><b>%CALC{"$TIMEDIFF( $TIME(), $EVAL($TIME()+90), minute )"}%</b></code> returns <code><b>1.5</b></code></td>
232   </tr>
233   <tr>
234     <td><code><b>"$TODAY()"</b></code></td>
235     <td> Get the serialized date of today at midnight GMT. The related <code>$TIME()</code> returns the serialized date of today at the current time, e.g. it includes the number of seconds since midnight GMT. See also <code>$FORMATTIME()</code>, <code>$FORMATGMTIME()</code>, <code>$TIMEDIFF()</code>. Example: <code><b>%CALC{"$TODAY()"}%</b></code> returns the number of seconds since Epoch </td>
236   </tr>
237   <tr>
238     <td><code><b>"$TRIM(text)"</b></code></td>
239     <td> Removes all spaces from text except for single spaces between words. Example: <code><b>%CALC{"$TRIM( eat  spaces  )"}%</b></code> returns <code><b>eat spaces</b></code>. </td>
240   </tr>
241   <tr>
242     <td><code><b>"$UPPER(text)"</b></code></td>
243     <td> The upper case string of a text. Example: <code><b>%CALC{"$UPPER( $T(R1:C5) )"}%</b></code> returns the upper case string of the text in cell <code><b>R1:C5</b></code></td>
244   </tr>
245 </table>
246
247 ## <a name="Bug Tracking Example"></a> Bug Tracking Example
248
249 <table border="1" cellpadding="0" cellspacing="0">
250   <tr>
251     <th bgcolor="#99CCCC"><strong> Bug#: </strong></th>
252     <th bgcolor="#99CCCC"><strong> Priority: </strong></th>
253     <th bgcolor="#99CCCC"><strong> Subject: </strong></th>
254     <th bgcolor="#99CCCC"><strong> Status: </strong></th>
255     <th bgcolor="#99CCCC"><strong> Days to fix </strong></th>
256   </tr>
257   <tr>
258     <td> Bug:1231 </td>
259     <td> Low </td>
260     <td> File Open ... </td>
261     <td> Open </td>
262     <td align="right"> 3 </td>
263   </tr>
264   <tr>
265     <td> Bug:1232 </td>
266     <td> High </td>
267     <td> Memory Window ... </td>
268     <td> Fixed </td>
269     <td align="right"> 2 </td>
270   </tr>
271   <tr>
272     <td> Bug:1233 </td>
273     <td> Medium </td>
274     <td> Usability issue ... </td>
275     <td> Assigned </td>
276     <td align="right"> 5 </td>
277   </tr>
278   <tr>
279     <td> Bug:1234 </td>
280     <td> High </td>
281     <td> No arrange ... </td>
282     <td> Fixed </td>
283     <td align="right"> 1 </td>
284   </tr>
285   <tr>
286     <td> Total: 4 </td>
287     <td> High: 2<br /> Low: 1<br /> Medium: 1 </td>
288     <td> . </td>
289     <td> Assigned: 1<br /> Fixed: 2<br /> Open: 1 </td>
290     <td align="right"> Total: 11 </td>
291   </tr>
292 </table>
293
294 The last row is defined as:
295
296     | Total: %CALC{"$ROW(-2)"}% \
297       | %CALC{"$COUNTITEMS( R2:C$COLUMN()..R$ROW(-1):C$COLUMN() )"}% | . \
298       | %CALC{"$COUNTITEMS( R2:C$COLUMN()..R$ROW(-1):C$COLUMN() )"}% \
299       |  Total: %CALC{"$SUM( R2:C$COLUMN()..R$ROW(-1):C$COLUMN() )"}% |
300
301 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.
302
303 ## <a name="%TOPIC% Settings"></a> %TOPIC% Settings
304
305 Plugin settings are stored as preferences variables. To reference a plugin setting write <code>**%&lt;plugin&gt;\_&lt;setting&gt;%**</code>, i.e. <code>**%SPREADSHEETPLUGIN\_SHORTDESCRIPTION%**</code>
306
307 - One line description, is shown in the [[TextFormattingRules]] topic:
308   - Set SHORTDESCRIPTION = Add spreadsheet calculation like `"$SUM( $ABOVE() )"` to tables located in %WIKITOOLNAME% topics.
309
310 - Debug plugin: (See output in `data/debug.txt`)
311   - Set DEBUG = 0
312
313 - Do not handle `%CALC{}%` tag in included topic while including topic: (default: 1)
314   - Set SKIPINCLUDE = 1
315
316 ## <a name="Plugin Installation Instructions"></a> Plugin Installation Instructions
317
318 **_Note:_** 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.
319
320 - Download the ZIP file from the %TOPIC% home
321 - Unzip <code>**SpreadSheetPlugin.zip**</code> in your twiki installation directory. Content: <table border="1" cellpadding="0" cellspacing="0">
322   <tr>
323     <th bgcolor="#99CCCC"><strong> File: </strong></th>
324     <th bgcolor="#99CCCC"><strong> Description: </strong></th>
325   </tr>
326   <tr>
327     <td><code><b>data/TWiki/%TOPIC%.txt</b></code></td>
328     <td> Plugin topic </td>
329   </tr>
330   <tr>
331     <td><code><b>data/TWiki/%TOPIC%.txt,v</b></code></td>
332     <td> Plugin topic repository </td>
333   </tr>
334   <tr>
335     <td><code><b>lib/TWiki/Plugins/%TOPIC%.pm</b></code></td>
336     <td> Plugin Perl module </td>
337   </tr>
338 </table>
339 - Test if the "Total" in the first table in this topic is correct.
340
341 ## <a name="Plugin Info"></a> Plugin Info
342
343 <table border="1" cellpadding="0" cellspacing="0">
344   <tr>
345     <td align="right"> Plugin Author: </td>
346     <td> TWiki:Main/PeterThoeny </td>
347   </tr>
348   <tr>
349     <td align="right"> Plugin Version: </td>
350     <td> 24 Oct 2003 </td>
351   </tr>
352   <tr>
353     <td align="right"> Change History: </td>
354     <td>  </td>
355   </tr>
356   <tr>
357     <td align="right"> 24 Oct 2003: </td>
358     <td> Added $SET(), $GET(), $MEDIAN(); added $SUMPRODUCT(), inspired by TWiki:Main/RobertWithrow; added $SUMDAYS(), contributed by TWiki:Main/SvenDowideit </td>
359   </tr>
360   <tr>
361     <td align="right"> 21 Oct 2003: </td>
362     <td> Added support for lists <code>(1, 2, 3)</code> and lists of table ranges <code>(R1:C1..R1:C5, R3:C1..R3:C5)</code> for all functions that accept a table range; added $TIMEADD(); in $TIMEDIFF() added week unit; in $FORMATTIME() changed $weekday to $wd and added $wday and $weekday </td>
363   </tr>
364   <tr>
365     <td align="right"> 14 Oct 2003: </td>
366     <td> Added $TIME(), $TODAY(), $FORMATTIME(), $FORMATGMTIME(), $TIMEDIFF() </td>
367   </tr>
368   <tr>
369     <td align="right"> 13 Oct 2003: </td>
370     <td> Added $MULT(), contributed by TWiki:Main/GerritJanBaarda </td>
371   </tr>
372   <tr>
373     <td align="right"> 30 Jul 2003: </td>
374     <td> Added $TRANSLATE() </td>
375   </tr>
376   <tr>
377     <td align="right"> 19 Jul 2003: </td>
378     <td> Added $FIND(), $NOP(), $REPLACE(), $SEARCH(), $SUBSTITUTE(), contributed by TWiki:Main/PaulineCheung </td>
379   </tr>
380   <tr>
381     <td align="right"> 19 Apr 2003: </td>
382     <td> Added $COUNTSTR(), $EXACT(), $IF(), $ROUND(), $TRIM(); added $FORMAT(), contributed by TWiki:Main/JimStraus; support <code>%</code> modulus operator in $EVAL, $INT, and $ROUND; fixed bug in $DEF </td>
383   </tr>
384   <tr>
385     <td align="right"> 07 Jun 2002: </td>
386     <td> Added $DEF(), contributed by TWiki:Main/MartinFuzzey; allow values with HTML formatting like <code>&lt;u&gt;102&lt;/u&gt;</code>, suggested by TWiki:Main/GladeDiviney; added SKIPINCLUDE setting </td>
387   </tr>
388   <tr>
389     <td align="right"> 12 Mar 2002: </td>
390     <td> Support for multiple functions per nesting level </td>
391   </tr>
392   <tr>
393     <td align="right"> 15 Jan 2002: </td>
394     <td> Added $CHAR(), $CODE() and $LENGTH() </td>
395   </tr>
396   <tr>
397     <td align="right"> 12 Nov 2001: </td>
398     <td> Added $RIGHT() </td>
399   </tr>
400   <tr>
401     <td align="right"> 12 Aug 2001: </td>
402     <td> Fixed bug of disappearing multi-column cells </td>
403   </tr>
404   <tr>
405     <td align="right"> 19 Jul 2001: </td>
406     <td> Fixed incorrect $SUM calculation of cell with value <code>0</code></td>
407   </tr>
408   <tr>
409     <td align="right"> 14 Jul 2001: </td>
410     <td> Changed to plug &amp; play </td>
411   </tr>
412   <tr>
413     <td align="right"> 01 Jun 2001: </td>
414     <td> Fixed insecure dependencies for $MIN and $MAX </td>
415   </tr>
416   <tr>
417     <td align="right"> 16 Apr 2001: </td>
418     <td> Fixed div by 0 bug in $AVERAGE </td>
419   </tr>
420   <tr>
421     <td align="right"> 17 Mar 2001: </td>
422     <td> Initial version </td>
423   </tr>
424   <tr>
425     <td align="right"> CPAN Dependencies: </td>
426     <td> none </td>
427   </tr>
428   <tr>
429     <td align="right"> Other Dependencies: </td>
430     <td> none </td>
431   </tr>
432   <tr>
433     <td align="right"> Perl Version: </td>
434     <td> 5.000 and up </td>
435   </tr>
436   <tr>
437     <td align="right"> Plugin Home: </td>
438     <td><a href="http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%" target="_top">http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%</a></td>
439   </tr>
440   <tr>
441     <td align="right"> Feedback: </td>
442     <td><a href="http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev" target="_top">http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev</a></td>
443   </tr>
444 </table>
445
446 **_Related Topics:_** [[TWikiPreferences]], [[TWikiPlugins]]
447
448 -- TWiki:Main/PeterThoeny - 24 Oct 2003