calculate num-columns-required correctly

This fix, calculates num-columns-required correctly based on which columns are used/not-used/merged. Earlier code did not consider merged columns.

Effectively with this fix, when you print report, on average it saves 2-3 pages per 12-15 pages.
Additional changes to column calculations

- Add some comments to remember why this was done
- Fix one error in the code