Anda mencari referensi tabel jarak jauh :
#+TBLNAME: tab1
| Nº | Description | Value |
|-----+-------------+-------|
| | TOTAL | 1 |
...
#+TBLNAME: tab10
| Nº | Description | Value |
|----+-------------+-------|
| | TOTAL | 2 |
tab-summary
| Description | Value |
|-------------------+-------|
| Total of Table 1 | 1 |
| Total of Table 10 | 2 |
|-------------------+-------|
| Grand Total | 3 |
#+TBLFM: @2$2=remote(tab1,@2$3)::@3$2=remote(tab10,@2$3)::@>$2=vsum(@I$2..@II$2)
Catatan, pertanyaan ini sudah memiliki jawaban di sana: Cara referensi nama tabel atau blok kode dalam mode-Org
Anda bahkan dapat menghasilkan tab-summary
secara otomatis. Ini mudah jika rumus dapat langsung ditulis ke dalam sel tabel. Berikut ini ctrl-c-ctrl-c-hook
memungkinkan Anda untuk menginstal semua rumus tabel dari sel.
(defun org-table-install-formulas ()
"Install formulas in cells starting with = or := at the bottom of the table as #+TBLFM line.
Do nothing when point is not inside a table."
(interactive)
(when (org-table-p)
(save-excursion
(goto-char (org-table-begin))
(org-table-next-field)
(while (progn
(org-table-maybe-eval-formula)
(looking-at "[^|\n]*|\\([[:space:]]*\n[[:space:]]*|\\)?[^|\n]*\\(|\\)"))
(goto-char (match-beginning 2)))
))
nil)
(add-hook #'org-ctrl-c-ctrl-c-hook #'org-table-install-formulas)
Pembuatan otomatis dari tabel jumlah-total ditunjukkan pada contoh berikut:
#+TBLNAME: tab1
| Nº | Description | Value |
|-----+-------------+-------|
| | TOTAL | 1 |
...
#+TBLNAME: tab2
| Nº | Description | Value |
|----+-------------+-------|
| | TOTAL | 2 |
#+TBLNAME: tab3
| Nº | Description | Value |
|----+-------------+-------|
| | TOTAL | 3 |
#+BEGIN_SRC emacs-lisp :var basename="tbl" start=1 stop=3
(append
'(("Description" "Value")
hline)
(cl-loop for i from start upto stop
collect (list (format "Total of Table %d" i) (format ":=remote(tab%d,@>$3)" i)))
'(
hline
("Grand Total" ":=vsum(@I$2..@II$2)")))
#+END_SRC
#+RESULTS:
| Description | Value |
|------------------+---------------------|
| Total of Table 1 | :=remote(tab1,@>$3) |
| Total of Table 2 | :=remote(tab2,@>$3) |
| Total of Table 3 | :=remote(tab3,@>$3) |
|------------------+---------------------|
| Grand Total | :=vsum(@I$2..@II$2) |
Contoh ini memperlihatkan tabel yang dihasilkan dari eksekusi blok sumber emacs lisp.
Jika Anda telah menginstal org-ctrl-c-ctrl-c-hook
titik tempat di atas dalam tabel jumlah total dan tekan C-c C-cAnda mendapatkan tabel berikut:
| Description | Value |
|------------------+-------|
| Total of Table 1 | 1 |
| Total of Table 2 | 2 |
| Total of Table 3 | 3 |
|------------------+-------|
| Grand Total | 6 |
#+TBLFM: @2$2=remote(tab1,@>$3)::@3$2=remote(tab2,@>$3)::@4$2=remote(tab3,@>$3)::@5$2=vsum(@I$2..@II$2)
remote
) dalam formula elisp?