Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto format numbers in org-mode spreadsheets

Tags:

emacs

org-mode

Is there any way to automatically force number of decimal places in an org-mode spreadsheet? So that 42 would be changed to 43.00 when I move to the next field?

Also, is there automatic formatting for thousands separators?

like image 223
banjomonster Avatar asked Nov 27 '11 19:11

banjomonster


2 Answers

If you want a field to auto-format when changing to the next one, you would need to use the auto-update row header # to indicate that fields in that row should auto-calc whenever TAB S-TAB or RET are pressed in that row (see Org-Manual).

Then if you include as a formula for that cell (I'm assuming that if you are wanting to enter the value manually you will not have a formula affecting that cell usually) that contains (for your 42 -> 42.00 example)

=$0;%.2f

Information before the = sign can be cell or column references depending if you want the formula to be applied to a single cell or to the entire column. (This is mentioned here)

I wasn't able to find any reference to thousands separators in org, it might not be possible at the moment.

like image 147
Jonathan Leech-Pepin Avatar answered Oct 19 '22 07:10

Jonathan Leech-Pepin


This link on Formula Syntax for Calc shows the various options for org-calc-default-modes, which will allow you to change the display format and precision.

like image 43
cm2 Avatar answered Oct 19 '22 08:10

cm2