Page 1 of 1

Exporting to word with run time paramters

PostPosted: Mon May 14, 2012 9:45 pm
by SmithaRSanthosh
I have a requirement where I need to create a docx and ppt file. There is a standard template but at times i may need to export multiple items.
For example , my standard template has a text and a graph. If I export Item A , there may be 5 graphs of the same kind and 5 texts. Can I handle this scenario in docx4j. I will know the number (5, in the example) only at run time.

Re: Exporting to word with run time paramters

PostPosted: Mon May 14, 2012 10:32 pm
by jason
Can you explain what you want to do in more detail?

Do you mean load the docx once only, then work with it 5 times? You should create a new WordprocessingMLPackage as a starting point each time.

Re: Exporting to word with run time paramters

PostPosted: Thu May 17, 2012 9:24 pm
by SmithaRSanthosh
I meant , I have to export ,say, an employee detail to a word file. I create a template and use it. I have graphs , texts and footnotes related to the employee content. I substitute the template values with actuals at run time.
Now my requirement says that I have to export multiple employees at the same time.
My question was can I re-use the template. I will need a single word doc which has repetitions of the template content.

Ex: if my template has :

Name
Age
Birth Place

My multiple export doc would have

Name
Age
Birth Place

Name
Age
Birth Place

Name
Age
Birth Place

if I select 3 employees for export. Can I do this using docx4j.

Re: Exporting to word with run time paramters

PostPosted: Fri May 18, 2012 9:29 pm
by jason
Sure, you can create 3 x docx, and program docx4j to merge them.

Alternatively, see http://www.docx4java.org/blog/2010/11/m ... documents/ - email me if you are interested in that.

Not sure what approach you are using to inject your run time parameters, but content control databinding is well supported by docx4j, and depending on your precise requirements, may even take care of your "repeat" needs.

Re: Exporting to word with run time paramters

PostPosted: Tue May 22, 2012 7:38 pm
by SmithaRSanthosh
Thank You Jason. I am looking into the link you referred to. Will get back to you on this.

For run time parameters I was using getJAXBNodesViaXPath to get text and then replace it with my original. Can you suggest any better way to do it?

Re: Exporting to word with run time paramters

PostPosted: Tue May 22, 2012 7:49 pm
by jason
SmithaRSanthosh wrote:For run time parameters I was using getJAXBNodesViaXPath to get text and then replace it with my original. Can you suggest any better way to do it?


Yes, use content control data binding :-)