Thank you for sending through your template. After some iterations we isolated and resolved this issue. It was due to duplication of customer and product IDs caused when adding and updating customers and products through the control panel.
The customer invoicing template download has been updated with this fix. If you have downloaded it before the date of this post, then you may download the updated version with this fix. If not, the current version does not contain this issue.