You would need to setup a Template grid on the document template with max 10 columns and maybe some non persistent helper entities to populate the templategrid as headers, before you generate the document.
--Edit—
So this is what I would try to do. This is your domain model you need and you need to popuplate is before generation of the document
This is your template
This could be your microflow to populate the template
***Sorry for the crappy Mendix Forum which wont allow me to properly embed my screenshots. If you right click the image and download you get the whole image...***
I'm also interested in the solution Sjors is refering to, not sure how he intends to do this. afaik there is no conditional visibility on columns.
The only solution i can come up with is this:
Create a table with 10 rows and 1 column.
Inside of the first row, you place a second table with 1 column, in the second row you place another table with 2 columns, etc.
And the use conditional visibility on the rows of the first table to show the desired table based on user input.
I hope this helps.