emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* spreadsheet in org
@ 2008-09-07 23:50 Richard G Riley
  2008-09-08  8:03 ` Thomas Baumann
  0 siblings, 1 reply; 6+ messages in thread
From: Richard G Riley @ 2008-09-07 23:50 UTC (permalink / raw)
  To: org-mode


Here is a straightforward spreadsheet:


* Test org-mode spreadsheet for cash books


|   | Name             |           Cash |
|---+------------------+----------------|
| _ |                  |    cashforward |
|   |                  |          68000 |
| _ |                  |       cashtake |
|   | cash takings     |           2340 |
| _ |                  |       cashbank |
|   | moved to bank    |           2000 |
|---+------------------+----------------|
| _ |                  |           cash |
| # | subtotal         |          68340 |
|---+------------------+----------------|
|   | emp1             |            315 |
|   | emp2             |            289 |
|   |                  |              0 |
|   |                  |              0 |
|---+------------------+----------------|
| _ |                  |          wages |
| # | total wages      |            604 |
|---+------------------+----------------|
| _ |                  | cashafterwages |
| # | Cash After Wages |          67736 |
|---+------------------+----------------|
#+TBLFM: $cash=$cashforward+$cashtake-$cashbank::$cashafterwages=$cash-$wages::$wages=vsum(@10$3..@13$3)

My questions are:

Can one not actually name a specific cell? Or must the name itself be
stored above or below the cell?

The wages field : how to generalise this to allow for rows to be
added/deleted in the emp1,emp2 block?

Or is there a totally better way to do this? I didnt see a way for all
fields to auto calculate when a certain field was changed. One has to
tab over the "#" in the left hand column. Or?

If you can suggest a neater approach please do - this is my first
attempt at an org-mode spreadsheet.

Oh yes, can one change the enter mode so that the field only edits if
you press enter first? And then it preselects the previous contents so a
single key other than cursor keys will wipe the previous contents?
Currently if I type "5" in the wages field above then, depending where
the cursor is, I get (for example) 6504.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: spreadsheet in org
  2008-09-07 23:50 spreadsheet in org Richard G Riley
@ 2008-09-08  8:03 ` Thomas Baumann
  2008-09-08  8:23   ` Richard G Riley
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Baumann @ 2008-09-08  8:03 UTC (permalink / raw)
  To: emacs-orgmode

Richard G Riley <rileyrgdev@googlemail.com> writes:

> Here is a straightforward spreadsheet:
>
>
> * Test org-mode spreadsheet for cash books
>
>
> |   | Name             |           Cash |
> |---+------------------+----------------|
> | _ |                  |    cashforward |
> |   |                  |          68000 |
> | _ |                  |       cashtake |
> |   | cash takings     |           2340 |
> | _ |                  |       cashbank |
> |   | moved to bank    |           2000 |
> |---+------------------+----------------|
> | _ |                  |           cash |
> | # | subtotal         |          68340 |
> |---+------------------+----------------|
> |   | emp1             |            315 |
> |   | emp2             |            289 |
> |   |                  |              0 |
> |   |                  |              0 |
> |---+------------------+----------------|
> | _ |                  |          wages |
> | # | total wages      |            604 |
> |---+------------------+----------------|
> | _ |                  | cashafterwages |
> | # | Cash After Wages |          67736 |
> |---+------------------+----------------|
> #+TBLFM: $cash=$cashforward+$cashtake-$cashbank::$cashafterwages=$cash-$wages::$wages=vsum(@10$3..@13$3)
>
> My questions are:

> Can one not actually name a specific cell? Or must the name itself be
> stored above or below the cell?

C-c'
gives you a nice interface to the table formulas, making names
almost obsolete

> The wages field : how to generalise this to allow for rows to be
> added/deleted in the emp1,emp2 block?

$wages = vsum(@-I..@-II)
will do the trick (sum between hlines)
apart from that, if you add rows using M-S-down your formulas will be
adjusted automatically.

> Or is there a totally better way to do this? I didnt see a way for all
> fields to auto calculate when a certain field was changed. One has to
> tab over the "#" in the left hand column. Or?

As the manual says: C-u C-c *
you might also want to look at the Tbl menu


> Oh yes, can one change the enter mode so that the field only edits if
> you press enter first? And then it preselects the previous contents so a
> single key other than cursor keys will wipe the previous contents?
> Currently if I type "5" in the wages field above then, depending where
> the cursor is, I get (for example) 6504.

The interface is already outstandingly smart: Try moving with the TAB
from one field to another or use enter to stay inside the column. You
will notice that the requested features are already present. Maybe, also
try another couple of spreadsheets :-) 

Thomas

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Re: spreadsheet in org
  2008-09-08  8:03 ` Thomas Baumann
@ 2008-09-08  8:23   ` Richard G Riley
  2008-09-08 10:48     ` Thomas Baumann
  0 siblings, 1 reply; 6+ messages in thread
From: Richard G Riley @ 2008-09-08  8:23 UTC (permalink / raw)
  To: Thomas Baumann; +Cc: emacs-orgmode

Thomas Baumann <dtbaumann@yahoo.de> writes:

> Richard G Riley <rileyrgdev@googlemail.com> writes:
>
>> Here is a straightforward spreadsheet:
>>
>>
>> * Test org-mode spreadsheet for cash books
>>
>>
>> |   | Name             |           Cash |
>> |---+------------------+----------------|
>> | _ |                  |    cashforward |
>> |   |                  |          68000 |
>> | _ |                  |       cashtake |
>> |   | cash takings     |           2340 |
>> | _ |                  |       cashbank |
>> |   | moved to bank    |           2000 |
>> |---+------------------+----------------|
>> | _ |                  |           cash |
>> | # | subtotal         |          68340 |
>> |---+------------------+----------------|
>> |   | emp1             |            315 |
>> |   | emp2             |            289 |
>> |   |                  |              0 |
>> |   |                  |              0 |
>> |---+------------------+----------------|
>> | _ |                  |          wages |
>> | # | total wages      |            604 |
>> |---+------------------+----------------|
>> | _ |                  | cashafterwages |
>> | # | Cash After Wages |          67736 |
>> |---+------------------+----------------|
>> #+TBLFM: $cash=$cashforward+$cashtake-$cashbank::$cashafterwages=$cash-$wages::$wages=vsum(@10$3..@13$3)
>>
>> My questions are:
>
>> Can one not actually name a specific cell? Or must the name itself be
>> stored above or below the cell?
>
> C-c'
> gives you a nice interface to the table formulas, making names
> almost obsolete

I dont see how - names make the formula readable.  How does this buffer
makes anything much easier in terms of cell referencing?

>
>> The wages field : how to generalise this to allow for rows to be
>> added/deleted in the emp1,emp2 block?
>
> $wages = vsum(@-I..@-II)
> will do the trick (sum between hlines)
> apart from that, if you add rows using M-S-down your formulas will be
> adjusted automatically.

Thats nice - thanks.

>
>> Or is there a totally better way to do this? I didnt see a way for all
>> fields to auto calculate when a certain field was changed. One has to
>> tab over the "#" in the left hand column. Or?
>
> As the manual says: C-u C-c *

That is not the same thing as auto recalculation as in excel or similar
: you must manually invoke it. This is easily forgotten (well by me :-;)

> you might also want to look at the Tbl menu
>
>
>> Oh yes, can one change the enter mode so that the field only edits if
>> you press enter first? And then it preselects the previous contents so a
>> single key other than cursor keys will wipe the previous contents?
>> Currently if I type "5" in the wages field above then, depending where
>> the cursor is, I get (for example) 6504.
>
> The interface is already outstandingly smart: Try moving with the TAB
> from one field to another or use enter to stay inside the column. You
> will notice that the requested features are already present. Maybe, also
> try another couple of spreadsheets :-) 

If I tab to a field above and press enter a new row appears. It is bound
to org-return. (Latest version). Also there is no preselection of the cell
contents so if I type "8" when I have tabbed to the "cashbank" field
above then I get "| 8 2040 |".

>
> Thomas
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: spreadsheet in org
  2008-09-08  8:23   ` Richard G Riley
@ 2008-09-08 10:48     ` Thomas Baumann
  2008-09-08 14:56       ` Richard G Riley
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Baumann @ 2008-09-08 10:48 UTC (permalink / raw)
  To: emacs-orgmode


>>> Or is there a totally better way to do this? I didnt see a way for all
>>> fields to auto calculate when a certain field was changed. One has to
>>> tab over the "#" in the left hand column. Or?
>>
>> As the manual says: C-u C-c *
>
> That is not the same thing as auto recalculation as in excel or similar
> : you must manually invoke it. This is easily forgotten (well by me :-;)
>

Fortunately, there is _no_ auto-recalculation, it would slow down
things significantly on large tables with complex formulas.


> If I tab to a field above and press enter a new row appears. It is bound
> to org-return. (Latest version). Also there is no preselection of the cell
> contents so if I type "8" when I have tabbed to the "cashbank" field
> above then I get "| 8 2040 |".

tab into the field and start writing... believe me, it works (org 6.06b
and all versions I used since the tables were introduced.)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Re: spreadsheet in org
  2008-09-08 10:48     ` Thomas Baumann
@ 2008-09-08 14:56       ` Richard G Riley
  2008-09-08 17:07         ` Carsten Dominik
  0 siblings, 1 reply; 6+ messages in thread
From: Richard G Riley @ 2008-09-08 14:56 UTC (permalink / raw)
  To: Thomas Baumann; +Cc: emacs-orgmode

Thomas Baumann <dtbaumann@yahoo.de> writes:

>>>> Or is there a totally better way to do this? I didnt see a way for all
>>>> fields to auto calculate when a certain field was changed. One has to
>>>> tab over the "#" in the left hand column. Or?
>>>
>>> As the manual says: C-u C-c *
>>
>> That is not the same thing as auto recalculation as in excel or similar
>> : you must manually invoke it. This is easily forgotten (well by me :-;)
>>
>
> Fortunately, there is _no_ auto-recalculation, it would slow down
> things significantly on large tables with complex formulas.

Well, clearly one would be able to turn it off in the case of excessive
load. In my case its unfortunate, rather than fortunate, since the
spreadsheets I have (or want to convert) are small and there is
negligible slowdown. To have to remember to refresh the entire
spreadsheet is a burden - not a large one I agree, but one which if
forgotten could lead to catastrophic financial reports :-;

>
>
>> If I tab to a field above and press enter a new row appears. It is bound
>> to org-return. (Latest version). Also there is no preselection of the cell
>> contents so if I type "8" when I have tabbed to the "cashbank" field
>> above then I get "| 8 2040 |".
>
> tab into the field and start writing... believe me, it works (org 6.06b
> and all versions I used since the tables were introduced.)

As I said above, when I tab in and start writing it adds to the existing
text. I do believe it might be different for you, but believe me, it
does not for me...

6.06b

Possibly it is some other mode interfering or we are at cross meanings
here - the cashbank example explains the scenario reasonably well I
think (or rather hope:-;).

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Re: spreadsheet in org
  2008-09-08 14:56       ` Richard G Riley
@ 2008-09-08 17:07         ` Carsten Dominik
  0 siblings, 0 replies; 6+ messages in thread
From: Carsten Dominik @ 2008-09-08 17:07 UTC (permalink / raw)
  To: Richard G Riley; +Cc: Thomas Baumann, emacs-orgmode


On Sep 8, 2008, at 4:56 PM, Richard G Riley wrote:

> Thomas Baumann <dtbaumann@yahoo.de> writes:
>
>>>>> Or is there a totally better way to do this? I didnt see a way  
>>>>> for all
>>>>> fields to auto calculate when a certain field was changed. One  
>>>>> has to
>>>>> tab over the "#" in the left hand column. Or?
>>>>
>>>> As the manual says: C-u C-c *
>>>
>>> That is not the same thing as auto recalculation as in excel or  
>>> similar
>>> : you must manually invoke it. This is easily forgotten (well by  
>>> me :-;)
>>>
>>
>> Fortunately, there is _no_ auto-recalculation, it would slow down
>> things significantly on large tables with complex formulas.
>
> Well, clearly one would be able to turn it off in the case of  
> excessive
> load. In my case its unfortunate, rather than fortunate, since the
> spreadsheets I have (or want to convert) are small and there is
> negligible slowdown. To have to remember to refresh the entire
> spreadsheet is a burden - not a large one I agree, but one which if
> forgotten could lead to catastrophic financial reports :-;

Hi Richard,

how about this code (can even go into .emacs):

(run-with-idle-timer 1.0 'repeat
    (lambda ()
      (and (eq major-mode 'org-mode)
	  (org-at-table-p)
	  (org-table-recalculate 'all))))


This will recalculate each time you are idle for more than 1 second  
with cursor inside the table.

This may get you into trouble when you have a formula that produces  
and error, in which case you can protect the call with a condition- 
case, or you can write yourself a function that does turn this feature  
on and off.

>>
>>
>>> If I tab to a field above and press enter a new row appears. It is  
>>> bound
>>> to org-return. (Latest version). Also there is no preselection of  
>>> the cell
>>> contents so if I type "8" when I have tabbed to the "cashbank" field
>>> above then I get "| 8 2040 |".
>>
>> tab into the field and start writing... believe me, it works (org  
>> 6.06b
>> and all versions I used since the tables were introduced.)
>
> As I said above, when I tab in and start writing it adds to the  
> existing
> text. I do believe it might be different for you, but believe me, it
> does not for me...

What is the setting of org-table-auto-blank-field ?

If it is t and the feature Thomas describes does not work, you have  
indeed got interference from some other  package.


- Carsten

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-09-08 17:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-07 23:50 spreadsheet in org Richard G Riley
2008-09-08  8:03 ` Thomas Baumann
2008-09-08  8:23   ` Richard G Riley
2008-09-08 10:48     ` Thomas Baumann
2008-09-08 14:56       ` Richard G Riley
2008-09-08 17:07         ` Carsten Dominik

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).