Quantcast
Channel: All Your Documents Archive - 65bit Software
Viewing all articles
Browse latest Browse all 131

Custom Formatting Of Numeric Values

$
0
0

A custom format allows the specification of how numeric values are formatted, for example:

[DECIMAL=.]
[THOUSANDS=,]
[PRECISION=2]
[PREFIX=$]
[SUFFIX=]
[REMOVE=.00]
[STRIPTRAILINGZEROS=YES]

Where the data contains values of a different types, each can be formatted independently. Take fields containing:

€12
12 EUR
12 USD
10.5 KG

Each type has an identifier used to pick the correct formatting options. This contains a regular expression. When matched to the data, the subsequent options are used. For example

<.*USD>
[DECIMAL=.]
[THOUSANDS=,]
[PRECISION=2]
[PREFIX=$]
<.*EUR>
[DECIMAL=,]
[THOUSANDS=.]
[PRECISION=2]
[PREFIX=€]
<€.>
[DECIMAL=,]
[THOUSANDS=.]
[PRECISION=2]
[PREFIX=€]
<.*KG>
[DECIMAL=,]
[THOUSANDS=.]
[PRECISION=1]
[PREFIX=]
[SUFFIX= Kilo]
<>
[DECIMAL=.]
[THOUSANDS=,]
[PRECISION=0]
[PREFIX=?]

so <.*USD> matches a field that ends in USD. <> indicates which options to use when no match is found. The formatted fields content is now shown as:

€12,00
€12,00
$12.00
10,6 Kilo

 

 

The post Custom Formatting Of Numeric Values appeared first on 65bit Software.


Viewing all articles
Browse latest Browse all 131

Trending Articles