Calc Macro

Version 29.1 by Jie Pan on 2021/03/17 19:20

calculatorPerform simple calculations and sums in Wiki tables
TypeXAR
Category
Developed by

Ludovic Dubost

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1

Installable with the Extension Manager

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

ParameterDescriptionPossible valuesDefault value
formulaFormula 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 columnsmultiplication of the 2 columns to the left of the current column
formatDisplay format of the resulting calculation. This uses DecimalFormat from java0.00 Euros0.00

Sample:

|=Desc|=Days|=Price|=Total HT|=Total TTC
|Test|3.5|600|{{calc formula="$B*$C"  format="0.00 Euros" /}}|{{calc formula="$D*1.196"  format="0.00 Euros" /}}

Result:

calc1.png

sum macro

ParameterDescriptionPossible valuesDefault value
typeVertical or Horizontal sum. Currently only vertical is supportedcolnone
formatDisplay format of the resulting sum. This uses DecimalFormat from java0.00 Euros0.00

Sample:

|=Description|=Number of days
|Project Manager|2.5
|Designer|1
|=Total|={{sum type="col" format="0.0 days" /}}

Result:

calc2.png

summary macro

ParameterDescriptionPossible valuesDefault value
typeHeading or Aggregate groupingheading or columnheading
titleTitle line to use for the summary table A standard title line is used by default
summarytitleSummary title to use for the summary table for the full summary line The text "Total" is used by default
format1Display format of the first element of the grouping. This uses DecimalFormat from java0.00 days0.00
format2Display format of the second element of the grouping. This uses DecimalFormat from java0.00 Euros0.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:

{{summary format1="0.0 days" format2="0 Euros"/}}

Result:

calc3.png

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:

  1. Log in the wiki with a user having Administration rights
  2. Go to the Administration page and select the Import category
  3. Follow the on-screen instructions to upload the downloaded XAR
  4. Click on the uploaded XAR and follow the instructions
  5. 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

Tags: table math
    

Get Connected