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?

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. :slight_smile:

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/232251


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!

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.

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