emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Charles Millar <millarc@verizon.net>
To: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: help for summing column when exporting table
Date: Fri, 19 Jun 2015 08:36:35 -0400	[thread overview]
Message-ID: <55840CD3.5030206@verizon.net> (raw)

How do you execute

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

while the following is being exported to LaTeX/pdf

begin

#+LATEX_CLASS: mysetup
#+LaTeX: \setlength{\extrarowheight}{1.0ex}

#+LaTeX: \begin{center}
#+LaTeX: \textbf{SCHEDULE A}\\
#+LaTeX: \textbf{PRINCIPAL RECEIVED}
#+LaTeX: \end{center}
#+BEGIN_LaTeX
\vspace{-10.0ex}
#+END_LaTeX

#+NAME: SCHEDA
#+begin_src rec :data foo.rec :type Finance :fields 
AssetDate,Description,Basis
  AccountSchedule = "A"
#+end_src

#+ATTR_LATEX: :environment longtable :align p{60pt}p{315pt}N{8}{2}
#+TBLNAME: SCHEDA
#+TBLFM: @>$>='(apply '+ '(@I$>..@>>$>));N%.2f

end

the table is generated from a recutils file and there are approximately 
16 other tables which are generated using essentially the same format 
(AccountSchedule= is different in each one), and some may be five or six 
columns rather than three. When I export to the pdf all the tables 
exported, except that the total is not executed before export. The 
SCHEDDA table, as shown in the .org file is

#+NAME: SCHEDA
#+begin_src rec :data foo.rec :type Finance :fields 
AssetDate,Description,Basis
  AccountSchedule = "A"
#+end_src
#+ATTR_LATEX: :environment longtable :align p{60pt}p{315pt}N{8}{2}
#+TBLNAME: SCHEDA
|  AssetDate | Description          |         Basis |
|----------------+----------------------+---------------|
| 2015-12-15 | xxxx                   | 385162.27 |
| 2015-12-15 | yyyyyyyyyyyyyy |   99962.29 |
| 2015-12-15 | zzzzz                  | 108185.37 |
|                    | Total                   |                   |
#+TBLFM: @>$>='(apply '+ '(@I$>..@>>$>));N%.2f


I believe that executing emacs lisp table formula (rather than the 
org-calc #+TBLFM: @>$>=vsum(@I$>..@>>$>);%.2f) may be the "way to go" 
and that a separate src block may be needed such as

#+NAME: schedtotal
#+begin_src emacs-lisp :results silent
(defun schedtotal ()
   (#+TBLFM: @>$>='(apply '+ '(@I$>..@>>$>));N%.2f))
#+end_src

for execution using :post schedtotal  in the header, so that once the 
table is generated the :post schedtotal will sum the last column and 
then the subtree will be exported with each table and its last column added.

I am attempting to learn emacs lisp and I have tried the above 
schedtotal, but the # is a problem; if you remove that then the ; may be 
problem since everything after that is a comment.

Any help as well as solution will be greatly appreciated.

Charlie Millar

                 reply	other threads:[~2015-06-19 12:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55840CD3.5030206@verizon.net \
    --to=millarc@verizon.net \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).