Number manipulation
Formatters can be chained with dynamic parameters to create complex operations, check out the example in Dynamic parameters.
convCurr( target, source )
converts from one currency to another
exchange rates are included by default
you can provide a new exchange rate for one report in
options.currencyRates
ofCarbone.render
or globally withCarbone.set
convCurr()
without parameters converts automatically fromoptions.currencySource
tooptions.currencyTarget
Parameters | Description | Type |
---|---|---|
target |
| string |
source |
| string |
Examples
round( precision )
rounds a number
same as
toFixed()
but it rounds number correctlyround(1.05, 1) = 1.1
Parameters | Description | Type |
---|---|---|
precision | number of decimal | number |
Examples
formatN( precision )
formats number according to the locale
applying a number of decimals depends on the report type:
for
ODS
/XLSX
, the number of decimals has to be formatted based on the text editorfor the other type of files, the number of decimals depends on the
precision
parameter passed to the formatter
Parameters | Description | Type |
---|---|---|
precision | [optional] number of decimals | number |
Examples
formatC( precisionOrFormat )
Parameters | Description | Type |
---|---|---|
precisionOrFormat | [optional] number of decimal, or specific format
| number |
Examples
add( )
Adds 2 numbers.
Examples
sub( )
Subtracts 2 numbers.
Examples
mul( )
Multiplies 2 numbers.
Examples
div( )
Divides 2 numbers.
Examples
int( )
Converts a number to an INT.
toEN( )
Converts a number with English specifications (decimal separator is a dot .
).
toFixed( )
Converts a number into string, keeping only decimals.
toFR( )
Converts a number with French specifications (decimal separator is a comma ,
).
Last updated