FWIW, the code in Miguel Ruiz's post earlier today

"TBLFM added to updated table as result of a emacs-lisp src block"

has pretty much answered my questions. Thank you, Miguel.

I'm not sure if it the most efficient or even elegant but here is what I came up with, so please comment and correct if there is a better way

#+Name: ATableP
#+begin_src rec data: Foo.rec :type Bar :fields date,Description,Amount :results silent
src emacs-lisp :var table=ATableP :exports results
  (setq table (cons 'hline table))
  (setq table (cons '("Date" "Description" "Inventory") table))
  (setq table (append table '(("|Total"))))
(setq table (append table '(("\n#+TBLFM: @>$>=vsum(@I$>..@>>$>);%.2f::"))))
#+ATTR_LATEX: :environment longtable :align p{60pt}p{280pt}N{8}{2}
| date | Description | Amount    | (resulting table, after C-c C-v s)
| 6-7   | blah            |     1.00      |
| 6-8   | blah blah    |    2.00       |
|         | Total           |    3.00        |

On 06/11/2015 03:45 PM, Charles Millar wrote:

I am learning how to use org-babel and want to export (LaTeX) a table with the final column added at final row, which should be inserted. The entire process would take place upon exporting to LaTeX/pdf

Desired result (roughly speaking)

| date | Description | Amount    |
| 6-7   | blah            |     1.00      |
| 6-8   | blah blah    |    2.00       |
| | | 3.00 | (this row to be inserted and then column 3 added) (Also nice if a hline were inserted before the last row)

The table is generated from a recutils data base and essentially this is the set up

#+Name: ATable
#+begin_src rec data: Foo.rec :type Bar :fields date,Description,Amount

#+TBLFM: @>$>=vsum(@I$>..@>>$>);%.2f

I have read Using Code Blocks in Org Tables in the Worg Babel Introduction and searched the lists and am not sure of how to implement this.

At the moment I am more interested in solving the column sum problem; i can kludge an added row using a dummy record in the database.

Charlie Millar

Reply via email to