Page 1 of 1

Dinamic column in the table

PostPosted: Wed Sep 30, 2020 10:47 pm
by alesky
Dear

in my scenario i have to introduce an iterative table where i don't know the rows and i don't know also the exact number of columns that are part of the table

more specifically this is a scentific table where the columns will change based on the number of test that are executed.
I have 3 column that are statics in the table (the first 2 and the last 1 ), but in the middle of this columns i could have 1 to X colum that i cannot define at level of template
becouse i don't know it unitl I don't start to analize the data to generate the document

the point that i'm interestend is to understand if exist a strategy to put in place using content controls to defin same sort of template that at least could semplify the generation of the docx document

My idea is to make a sort of mixed scenario where i do the table with the static columns that i know in the template and i already link the repeat content control wiht the columns that i already know to it

and at run time during the processing of the template i discover the amount of column and then
    1 - add in the table by code extra column,
    2 - add in the table by code the content controls for the new column
    3 - i push in the word document the custom xml wiht the new column

is there same other strategy that i could consider before to start to analize in detail this approach?

Re: Dinamic column in the table

PostPosted: Thu Oct 01, 2020 11:22 am
by jason
Interesting question.

Repeating rows are easy to handle already, using OpenDoPE.

A straightforward way to explore repeating columns would be to have a single column with a delimiter in it, for example the ^ character.

Then, after OpenDoPE processing is completed, the column is replicated.

For example, a cell contains "A^B^C", this becomes 3 cells in a row, containing A,B,C respectively.

Limitations:
- may need to use auto layout, not fixed http://webapp.docx4java.org/OnlineDemo/ ... out_1.html and easier to avoid http://webapp.docx4java.org/OnlineDemo/ ... rid_1.html and http://webapp.docx4java.org/OnlineDemo/ ... idCol.html
- avoid merged columns

On this approach, a cell would be bound via XPath to a single XML element containing "A^B^C"

I imagine the content control would contain a tag instructing the processor to "expand columns"