Date: Tue, 29 Jul 2014 10:42:12 +0000
Mime-Version: 1.0 (Produced by PhpWiki 1.5.0)
Content-Type: application/x-phpwiki;
  pagename=Help%2FSpreadsheet;
  flags=PAGE_LOCKED%2CEXTERNAL_PAGE;
  charset=UTF-8
Content-Transfer-Encoding: binary

Phpwiki has extented the [[Help:Wikicreole|Wikicreole]] syntax of tables so that some simple
spreadsheet-like calculations can be performed in tables.

== Syntax ==

Five functions are available: SUM, AVERAGE, MAX, MIN and COUNT.

They operate on the current row (R) or column (C).

The function is placed in the cell surrounded by ##@@##.
Other wiki text can be placed in the cell, but there can be only one formula per cell.

{| class="bordered"
|-
! Formula !! Meaning
|-
| @@=SUM(R)@@ || Sum of cells in current row
|-
| @@=SUM(C)@@ || Sum of cells in current column
|-
| @@=AVERAGE(R)@@ || Average of cells in current row
|-
| @@=AVERAGE(C)@@ || Average of cells in current column
|-
| @@=MAX(R)@@ || Maximum value of cells in current row
|-
| @@=MAX(C)@@ || Maximum value of cells in current column
|-
| @@=MIN(R)@@ || Minimum value of cells in current row
|-
| @@=MIN(C)@@ || Minimum value of cells in current column
|-
| @@=COUNT(R)@@
| Number of cells in current row (numeric or not, excluding headers and current cell)
|-
| @@=COUNT(C)@@
| Number of cells in current column (numeric or not, excluding headers and current cell)
|}

== Examples ==

=== Sum ===

{{{
|=Region          |=Telecom Sales  |=Power Sales |=Other       |=TOTAL      |
|=Europe          |            320 |          80 |         120 |@@=SUM(R)@@ |
|=Asia            |            580 |         723 |         564 |@@=SUM(R)@@ |
|=North America   |            235 |          60 |         109 |@@=SUM(R)@@ |
|=South America   |            120 |          35 |          82 |@@=SUM(R)@@ |
|=Antarctica      |              0 |           0 |          12 |@@=SUM(R)@@ |
|=TOTAL           |    @@=SUM(C)@@ | @@=SUM(C)@@ | @@=SUM(C)@@ |Grand total: @@=SUM(R)@@ |
}}}

|=Region          |=Telecom Sales  |=Power Sales |=Other       |=TOTAL      |
|=Europe          |            320 |          80 |         120 |@@=SUM(R)@@ |
|=Asia            |            580 |         723 |         564 |@@=SUM(R)@@ |
|=North America   |            235 |          60 |         109 |@@=SUM(R)@@ |
|=South America   |            120 |          35 |          82 |@@=SUM(R)@@ |
|=Antarctica      |              0 |           0 |          12 |@@=SUM(R)@@ |
|=TOTAL           |    @@=SUM(C)@@ | @@=SUM(C)@@ | @@=SUM(C)@@ |Grand total: @@=SUM(R)@@ |

Total of both colums and rows is calculated automatically by wiki.

=== Count and Sum ===

{{{
|=Bug                |=Priority   |=Subject             |=Status     |=Days to fix
| 1231               | Low        | File Open ...       | Open       | 3
| 1232               | High       | Memory Window ...   | Fixed      | 2
| 1233               | Medium     | Usability issue ... | Assigned   | 5
| 1234               | High       | No arrange ...      | Fixed      | 1
| Number of bugs: @@=COUNT(C)@@ | |                     |            | Total: @@=SUM(C)@@ days
}}}

|=Bug                |=Priority   |=Subject             |=Status     |=Days to fix
| 1231               | Low        | File Open ...       | Open       | 3
| 1232               | High       | Memory Window ...   | Fixed      | 2
| 1233               | Medium     | Usability issue ... | Assigned   | 5
| 1234               | High       | No arrange ...      | Fixed      | 1
| Number of bugs: @@=COUNT(C)@@ | |                     |            | Total: @@=SUM(C)@@ days

=== Min, Max and Average ===

{{{
|=Location            |=Morning     |=Noon        |=Evening     |=Average temperature |
| Paris               | 7           | 13          | 10          | @@=AVERAGE(R)@@     |
| London              | 3           | 10          | 8           | @@=AVERAGE(R)@@     |
| Berlin              | 9           | 15          | 12          | @@=AVERAGE(R)@@     |
| Tokyo               | 12          | 20          | 16          | @@=AVERAGE(R)@@     |
| Maximum temperature | @@=MAX(C)@@ | @@=MAX(C)@@ | @@=MAX(C)@@ |                     |
| Minimum temperature | @@=MIN(C)@@ | @@=MIN(C)@@ | @@=MIN(C)@@ |                     |
}}}

|=Location            |=Morning     |=Noon        |=Evening     |=Average temperature |
| Paris               | 7           | 13          | 10          | @@=AVERAGE(R)@@     |
| London              | 3           | 10          | 8           | @@=AVERAGE(R)@@     |
| Berlin              | 9           | 15          | 12          | @@=AVERAGE(R)@@     |
| Tokyo               | 12          | 20          | 16          | @@=AVERAGE(R)@@     |
| Maximum temperature | @@=MAX(C)@@ | @@=MAX(C)@@ | @@=MAX(C)@@ |                     |
| Minimum temperature | @@=MIN(C)@@ | @@=MIN(C)@@ | @@=MIN(C)@@ |                     |

== Limitations ==

The formulas are evaluated line per line, from left to right.

So this will work:

{{{
|          10 |         -13 | @@=SUM(R)@@ |
|          15 |          17 | @@=SUM(R)@@ |
| @@=SUM(C)@@ | @@=SUM(C)@@ | @@=SUM(R)@@ |
}}}

|          10 |         -13 | @@=SUM(R)@@ |
|          15 |          17 | @@=SUM(R)@@ |
| @@=SUM(C)@@ | @@=SUM(C)@@ | @@=SUM(R)@@ |

And this will not:

{{{
| @@=SUM(R)@@ |          10 |         -13 |
| @@=SUM(R)@@ |          15 |          17 |
| @@=SUM(R)@@ | @@=SUM(C)@@ | @@=SUM(C)@@ |
}}}

| @@=SUM(R)@@ |          10 |         -13 |
| @@=SUM(R)@@ |          15 |          17 |
| @@=SUM(R)@@ | @@=SUM(C)@@ | @@=SUM(C)@@ |

== Author ==

* Marc-Etienne Vargenau, Alcatel-Lucent

<noinclude>
----
[[PhpWikiDocumentation]]
</noinclude>
