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
target
[optional] convert to this currency ('EUR')
by default it equals
options.currencyTarget
string
source
[optional] currency of source data ('USD')
by default it equals
options.currencySource
string
Examples
round( precision )
rounds a number
same as
toFixed()
but it rounds number correctlyround(1.05, 1) = 1.1
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
precision
[optional] number of decimals
number
Examples
formatC( precisionOrFormat )
precisionOrFormat
[optional] number of decimal, or specific format
integer : change default precision of the currency
M : print major currency name without the number
L : prints number with currency symbol (by default)
LL : prints number with major currency name
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