Report with repeated columns and spanned cells in heading

We have prepared a patch that fixes this bug:

Here is a document generated from the first template after fixing:

This patch also fixes the following bug:
Strange column widths in report with repeated columns