Emacs: Org-mode spreadsheet: targeting via hline

别来无恙 提交于 2019-12-07 16:47:18

问题


I'm trying to log my hours in org mode:

** Bob Johnson, Bob's SEO
| subject                                       | time                      | minutes | total hours |
|-----------------------------------------------+---------------------------+---------+-------------|
| optimization report                           | 2011/07/11 8-10:00 PM PST |     120 |           2 |
| phonecall to dicuss report and plan of action | 2011/07/13 5:41 PM        |      43 |  0.71666667 |
|-----------------------------------------------+---------------------------+---------+-------------|
|                                               |                           |     249 |        4.15 |
#+TBLFM: $4=@0$-1/60::@6$3=vsum(@I..@II)

The main problem is the expression above that sums up total hours:

@6$3=vsum(@I..@II)

Should be something like:

@||+1$3=vsum(@I..@II)

So that as the spread sheet grows the last item in the second to last column will always sum the total. It doesn't work when I set it this way (and +II, and other ways) however.

Any ideas?

Thanks!


回答1:


The closest you could come to relative references would be to change your formula to:

#+TBLFM: $4=$-1/60::@>$3=vsum(@I..@II)

The @0 is implied by -1.

For the second formula the @> means the last row, so as long as you don't add additional rows below your total row the results will be in the right place. If you add additional below it you will simply have to adjust the number of > signs.

EDIT:

You can also name the cell in question so that it doesn't get changed regardless: Org-Manual

|-----------------------------------------------+---------------------------+---------+-------------|
|                                               |                           |     163 |   2.7166667 |
| ^                                             |                           |   total |       total |
#+TBLFM: $4=$-1/60::$total=vsum(@I..@II)

You need the total name for both total rows, otherwise your minutes won't add up.




回答2:


Use the M-S-up,down,left,right family of commands to manipulate (insert/delete row/column) the table, and the formula will be adjusted automatically.



来源:https://stackoverflow.com/questions/6689424/emacs-org-mode-spreadsheet-targeting-via-hline

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!