My Word document has the following structure:
- Code: Select all
«TITRE»
«NOM» «PRENOM»
«RUE_NUM»
«NPA» «LOCALITE»
«Next Record»«TITRE»
«NOM» «PRENOM»
«RUE_NUM»
«NPA» «LOCALITE»
«Next Record»«TITRE»
«NOM» «PRENOM»
«RUE_NUM»
«NPA» «LOCALITE»
And I use the getConsolidatedResultCrude method from MailMerger to merge a List of map field. (In this case I give a list with 2 elements inside)
- Code: Select all
private WordprocessingMLPackage mergeFileData(WordprocessingMLPackage wordMLPackage, List<Map<DataFieldName, String>> mapFields) {
MailMerger.setMERGEFIELDInOutput(OutputField.KEEP_MERGEFIELD);
try {
return MailMerger.getConsolidatedResultCrude(wordMLPackage, mapFields);
} catch (Docx4JException e) {
LOGGER.error("Error when merging data and template", e);
throw new RuntimeException(e);
}
}
And the result in generate file is
- Code: Select all
Madame
Dupond Léa
Chemin 11
1219 Genève
«Next Record»Madame
Dupond Léa
Chemin 11
1219 Genève
«Next Record»Madame
Dupond Léa
Chemin 11
1219 Genève
BREAK SECTION
Monsieur
Doe John
Rue Marterey 5
1005 Lausanne
«Next Record»Monsieur
Doe John
Rue 5
1005 Lausanne
«Next Record»Monsieur
Doe John
Rue 5
1005 Lausanne
and the result I'd like to have
- Code: Select all
Madame
Dupond Léa
Chemin 11
1219 Genève
Monsieur
Doe John
Rue 5
1005 Lausanne
Is MailMerger able to use the NEXT instruction from MergeField or how it's possible to update my code or template to solve this problem.
Thanks
Sébastien