How can I automatically calculate sums in a LaTeX table?
LaTeX is a typesetting system, and trying to use it for anything other than that will probably lead you to frustration at some point or another. Unless your table is really very simple, I think going for a spreadsheet and then exporting that to LaTeX is definitely the best way to go.
Now, having said that, for a simple table you can use, as Thorsten suggested, a package like spreadtab and write something like:
\begin{spreadtab}{{tabular}{llll|l}}
& @ Foo & @ Bar & @ Baz & \\
@ Small & 5 & 3 & 11 & sum(b2:d2) \\
@ Medium & 9 & 2 & 23 & sum(b3:d3) \\
@ Large & 13 & 15 & 44 & sum(b4:d4) \\ \hline
& sum(b2:b4) & sum(c2:c4) & sum(d2:d4) &
\end{spreadtab}
Run texdoc spreadtab
on a command line to get its documentation and read the full details.
Try your luck with calctab, spreadtab or tabularcalc.
If you want symbolic calculations (instead of the very cool spreadsheet options Thorsten gave) both Sage and Mathematica have ways of mixing themselves with LaTeX.
Here's an example from the SageTex tutorial:
\documentclass{article}
\usepackage{sagetex}
\begin{document}
Using Sage\TeX, one can use Sage to compute things and put them into
your \LaTeX{} document. For example, there are
$\sage{number_of_partitions(1269)}$ integer partitions of $1269$.
You don't need to compute the number yourself, or even cut and paste
it from somewhere.
Here's some Sage code:
\begin{sageblock}
f(x) = exp(x) * sin(2*x)
\end{sageblock}
The second derivative of $f$ is
\[
\frac{\mathrm{d}^{2}}{\mathrm{d}x^{2}} \sage{f(x)} =
\sage{diff(f, x, 2)(x)}.
\]
Here's a plot of $f$ from $-1$ to $1$:
\sageplot{plot(f, -1, 1)}
\end{document}