Hi,
I attached a .doc template on which I’m working, that represents an HSE department audit created by our software.
As you see, there are many merge regions, and also many merge fields outside any regions.
The mail merge operation is NOT done within a single call, but rather following this steps:
- get all outside fields’ values
- get “ispettori” and “ispettore” regions
- get “associazioni” and “associazione” regions
- get “categoria” and “domanda” regions
- get “matrici”, “verifica” and “criterio” regions
- get “audit” and “punti_verifica” regions
- get “grafici” region
It is done this way so that each method returns its own DataSet with required DataTable and DataRelation set, then the merging is done like this:
merge(doc, this.getVerbale());
merge(doc, this.getAssociazioni(this.getModuleFrom(), this.getParam("id_valutazione")));
merge(doc, this.getChecklist());
merge(doc, this.getMatrici());
merge(doc, this.getRisultato());
merge(doc, this.getGrafico(), "grafici");
The first and last call simply merge a ResultSet, the other are all DataSet with proper names and relation set.
Also, I have setup mailmerge like this:
MailMerge merge = doc.getMailMerge();
merge.setFieldMergingCallback(this);
merge.setCleanupOptions(MailMergeCleanupOptions.REMOVE_UNUSED_REGIONS | MailMergeCleanupOptions.REMOVE_UNUSED_FIELDS);
I am facing the following problems:
-
If I just remove the lines doing the actual merge, I get a document with all the merge fields and regions still in place, despite the cleanup options I set
-
If I restore the removed line to try to fill the document, it fails, but I seem to be unable to get any error nor stacktrace out of it, even if the code is made so that each error should generate an exception with full stack trace
Can you help me with this issue?
Thanks in advance.