# Writer: the sum of a table column in the status bar

I have many documents with tables in Writer, and I need to check if the sum of numbers in certain columns is correct. How can I do this, preferably without changing the document? For example, Calc shows the sum of the selected column in the status bar, but this does not seem to be the case for Writer.

Yes, I could insert a cell, put the column sum into it and later undo the changes, but I was wondering if it is possible to find the sum without changing the document in order to avoid errors such as accidentally saving the document. Perhaps there is an easy to find the sum of numbers in the clipboard in Linux?

edit retag close merge delete

Sort by » oldest newest most voted

This strikes me as an interesting problem, and one with many potential solutions! Of course, it would be great to be able to modify the statusbar behaviour in Writer so that the table info displayed for a selected column isn't in the format Table1:B1:B5 (or whatever), but would give Calc's Average: 3; Sum: 15 (or whatever!). But I can't work out how to do that. There might also be some "macro" solution, but I can't work that out either. :)

Since you're using Linux of some flavour, here's something that would work.

1. Open a plain text file (in your favourite text editor; gedit would do), and save it (e.g. "colnum.txt").
2. To check your table-column from Writer, select-copy that column, Alt-TAB to your editor, paste the contents of clipboard, then Ctrl-S to save.
3. In terminal (in the same directory as the file, or modify below to reflect true path-to-file), run the following line:

$awk '{s+=$1} END {print s}' colnum.txt

And that will "print" to screen the sum of your column.¹

For subsequent columns (assuming you're doing lots of these, one after the other), just keep that text file open, and after refreshing it's contents (Ctrl-A > Ctrl-V to replace contents > Ctrl-S to save new values), all you have to do in the terminal is press the [↑] up-arrow key, hit "Enter", and get your new value.

It actually goes very fast once it's set up. NOT (I know) an ideal solution, but it's a start. (There are ways of taking input directly from the clipboard in Linux, but that requires third-party apps. This solution is "native".)

¹ HT: https://stackoverflow.com/q/450799/23...

To show the community your question has been answered, click the ✓ next to the correct answer, and "upvote" by clicking on the ^ arrow of any helpful answers. These are the mechanisms for communicating the quality of the Q&A on this site. Thanks!

more

1

Thanks. I ended up bypassing the editor and using the xclip command to extract numbers directly from the clipboard as described here and then using bc to add them together as described here. So I select a column in Writer, switch to the terminal and hit the up arrow key to recall the command xclip -o | paste -s -d + - | bc.

( 2018-07-20 00:01:42 +0200 )edit

@Evgeny.M - Nice solution! It's a shame xclip isn't installed by default, but it's easy to get, and is extremely useful. Thanks for the interesting question.

( 2018-07-20 11:28:03 +0200 )edit

## Stats

Asked: 2018-07-06 22:17:13 +0200

Seen: 108 times

Last updated: Jul 07 '18