Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: include financial units - number formatting options #288

Open
murilo-s opened this issue Mar 13, 2024 · 2 comments
Open

Idea: include financial units - number formatting options #288

murilo-s opened this issue Mar 13, 2024 · 2 comments

Comments

@murilo-s
Copy link
Sponsor

Quick suggestion:

Include some basic financial units, like the dollar sign $, day, month, year, apy.

Also, make it possible to change number formatting, to show x.xxx,xx or $x.xxx,xx for example

Thanks.

@Proektsoftbg
Copy link
Owner

Hi! Thank you for your suggestion. Currently, custom number formatting is not implemented in Calcpad and this is something we can improve in future. However, there is some options to use JavaScript to format numbers. I will post some code later.

@Proektsoftbg
Copy link
Owner

Hi!

Here is some useful example how to format a table with prices as currency:
image

The source code is the following:

price_conc = 12001.34567
price_steel = 52005.34567
#val
'<table class="bordered">
'<thead>
'<tr><th>Item</th><th>Price, USD</th></tr>
'</thead>
'<tbody>
'<tr><td>Concrete</td><td class="usd">'price_conc'</td></tr>
'<tr><td>Steel</td><td class="usd">'price_steel'</td></tr>
'</tbody>
'</table>
#equ
'<script>var USDollar = new Intl.NumberFormat("en-US", {style: "currency",currency: "USD",}); $(".usd").each(function(){$(this).text(USDollar.format(parseFloat($(this).text())));});</script>

The key is to add this little script at the end and class="usd" to the html element that encloses the currency value.
This works only in #val section where only numbers are present in the output and not variables and equations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants