0

I can use following code to create sum of numbers. But how can I append some text?

#+TBLFM: $4=$2+$1+$3

For example

| 名字   | 内容1        | 内容2                | 结果 results  |
|--------+--------------+----------------------+--------|
| Mr. 域| dear | happy | dear Mr. 域 happy  |
  • 1
    You can use Emacs Lisp in formulas, for example #+tblfm: $4=(format "%d+%d=%d" $1 $2 (+ $1 $2));L should put x+y=z in the fourth column. – wvxvw Dec 31 '15 at 15:21
  • Ouch, I forgot the quote, Lisp expression needs to start with a '. – wvxvw Dec 31 '15 at 18:49
2

See Section "3.5.3 Emacs Lisp forms as formulas" of the orgmode manual or see http://orgmode.org/worg/org-tutorials/org-spreadsheet-lisp-formulas.html.

The lisp expression is introduced by a single quote and embraced in parentheses. You can use cell references in the lisp expression. They are replaced by the cell entries as string by default. But you can change these defaults through flags like 'N' (standing for Numeric) as in the comment of wvxvw. Consult the manual for further information.

In the following you find an example for your special case.

| 名字   | 内容1 | 内容2 | 结果 results    |
|--------+-------+-------+-------------------|
| Mr. 域 | dear  | happy | dear Mr. 域 happy |
#+TBLFM: $4='(format "%s %s %s" $2 $1 $3)
1

Use formulas, as suggested by @wvxvw in the comments. mapconcat is a nice option for joining strings:

| 名字   | 内容1 | 内容2 | 结果 results      |
|--------+-------+-------+-------------------|
| Mr. 域 | dear  | happy | dear Mr. 域 happy |
#+TBLFM: $4='(mapconcat 'identity (list $2 $1 $3) " ")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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