issue #21399: Add totals to worksheet.

Also other critical calculation fixes.