Calc Macro
Perform simple calculations and sums in Wiki tables |
Type | XAR |
Category | |
Developed by | |
Rating | |
License | GNU Lesser General Public License 2.1 |
Table of contents
Description
These macros allow to do simple calculation and sums in Wiki tables. It also allows to generate summary tables from multiple tables.
calc macro
Parameter | Description | Possible values | Default value |
---|---|---|---|
formula | Formula to use for the calculation in velocity | $B * $C or $row.get(2) * $row.get(3) for rows or $b*$c or $col.get(2) * $col.get(3) for columns | multiplication of the 2 columns to the left of the current column |
format | Display format of the resulting calculation. This uses DecimalFormat from java | 0.00 Euros | 0.00 |
Sample:
|Test|3.5|600|{{calc formula="$B*$C" format="0.00 Euros" /}}|{{calc formula="$D*1.196" format="0.00 Euros" /}}
Result:
sum macro
Parameter | Description | Possible values | Default value |
---|---|---|---|
type | Vertical or Horizontal sum. Currently only vertical is supported | col | none |
format | Display format of the resulting sum. This uses DecimalFormat from java | 0.00 Euros | 0.00 |
Sample:
|Project Manager|2.5
|Designer|1
|=Total|={{sum type="col" format="0.0 days" /}}
Result:
summary macro
Parameter | Description | Possible values | Default value |
---|---|---|---|
type | Heading or Aggregate grouping | heading or column | heading |
title | Title line to use for the summary table | A standard title line is used by default | |
summarytitle | Summary title to use for the summary table for the full summary line | The text "Total" is used by default | |
format1 | Display format of the first element of the grouping. This uses DecimalFormat from java | 0.00 days | 0.00 |
format2 | Display format of the second element of the grouping. This uses DecimalFormat from java | 0.00 Euros | 0.00 |
In mode "heading", elements are grouped by the heading of the section in which the table is. The second and third column values of the last row of each table is used for the aggragation as shown in the sample.
In mode "column", elements are grouped by the value of the first column. The second and third column values of each row of each tables are aggregated except the last row of each table.
Sample:
Result:
Prerequisites & Installation Instructions
We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager). Note that installing Extensions when being offline is currently not supported and you'd need to use some complex manual method.
You can also use the following manual method, which is useful if this extension cannot be installed with the Extension Manager or if you're using an old version of XWiki that doesn't have the Extension Manager:
- Log in the wiki with a user having Administration rights
- Go to the Administration page and select the Import category
- Follow the on-screen instructions to upload the downloaded XAR
- Click on the uploaded XAR and follow the instructions
- You'll also need to install all dependent Extensions that are not already installed in your wiki
Import the XAR and visit pages Macros.Calc Macros.Sum and Macros.Summary
Release Notes
v1.1
Fix performance issue caused by print calls in the CalcGroovy
v1.0
Initial support for calc, sum and summary macros