plutext / docx4j

JAXB-based Java library for Word docx, Powerpoint pptx, and Excel xlsx files
https://www.docx4java.org/
2.05k stars 1.19k forks source link

MailMerger performMerge on mergefields in textboxes #93

Open akuehntopf opened 10 years ago

akuehntopf commented 10 years ago

The following scenario used to work in the latest 2.x versions, but not any more in 3.x:

1) Setup a Word template (docx) containing a textbox with a mergefield inside. 2) Call MailMerger.performMerge on the document 3) The following exception is raised:

org.docx4j.openpackaging.exceptions.Docx4JException: Unexpected parent: org.docx4j.vml.CTTextbox
    at org.docx4j.model.fields.merge.MailMerger.performOnInstance(MailMerger.java:489) ~[docx4j-3.0.0.jar:na]
    at org.docx4j.model.fields.merge.MailMerger.performMerge(MailMerger.java:387) ~[docx4j-3.0.0.jar:na]

In 2.x the mergefield is correctly replaced, no exception is raised.

mikeblum commented 10 years ago

Not a developer for docx4j, but I'm working on using the MailMerger. In what version of word does this happen?

plutext commented 10 years ago

It works in a Java (or .NET) environment, not in Word. It take a suitable docx file as input, and produces docx as output (compatible with Word 2007 and later).

On Sun, Apr 20, 2014 at 4:40 AM, Michael Blum notifications@github.comwrote:

Not a developer for docx4j, but I'm working on using the MailMerger. In what version of word does this happen?

— Reply to this email directly or view it on GitHubhttps://github.com/plutext/docx4j/issues/93#issuecomment-40877197 .