Search code examples
emacsorg-mode

How to achieve a row index column in Emacs Org Mode using a Calc column rule


I would like to have a column in an org mode table that is a simple monotonically increasing value, i.e. the row number such that wnen I insert and remove random rows the index value adjusts automagically. I suspect that this should be simple but it would appear I am making it way too difficult. Mind you, I am a novice at using Emacs and org mode to build spreadsheets. So a simple example spreadsheet where there are two columns, one the row index value and the other some fixed value, would be a perfect answer.


Solution

  • This example uses @# to get the row number. Similarly, $# returns the column number.

    | row | data |
    |-----+------|
    | 2   | 0303 |
    | 3   | 5123 |
    | 4   | 41   |
    | 5   | 4234 |
    #+TBLFM: $1=@#