1

I am trying to rename a row inside a table using a formula in Org mode (don't ask why I'm doing this, I need to do it that way) but I'd like to call this row #. I'm doing this:

| #ERROR | B | C |
|--------+---+---|
|      1 | 2 | 3 |
|      1 | 2 | 3 |
#+TBLFM: @1$1=#

As you can see I'm getting an error. I guess that's because # is a special character reserved to indicate line numbers.

So I'd like to know how to escape this character to interpret it as a normal string.

1
  • 1
    Use C-c { to turn on the formula debugger to see what error is generated. In this case, it says Error: #'s not allowed in this context; that's an error generated by Calc when it reads the formula, so using an elisp formula (as in the answer below) is probably benign, as long as you don't use that cell in another formula.
    – NickD
    Aug 5, 2021 at 13:09

1 Answer 1

3

The following works because you can write table formulas with elisp code. Notice the ' (quote) before the s-exp.

| # | B | C |
|---+---+---|
| 1 | 2 | 3 |
| 1 | 2 | 3 |
#+TBLFM: @1$1='(format "#")

Evaluate (info "(org) Formula syntax for Lisp") for more information.

1
  • 1
    This should work as long as you don't try to calculate with it (@1$1 should not be used in any formula).
    – NickD
    Aug 5, 2021 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.