We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose words java

hi how to include multiple values to single merge field

using aspose words java?


Thanks for your inquiry. Please see attached sample input/output Word documents and try running the following code:
Document doc = new Document(getMyDir() + “in.docx”);
doc.getMailMerge().setFieldMergingCallback(new HandleMergeField());
doc.getMailMerge().execute(new String[]{“mf”}, new Object[]{Hello});
doc.save(getMyDir() + “15.10.0.docx”);

static class HandleMergeField implements IFieldMergingCallback
public void fieldMerging(FieldMergingArgs e) throws Exception
if (e.getFieldName().equals(“mf”)) {
Document doc = (Document) e.getDocument();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write(e.getFieldValue().toString() + " " + “World) ;
<font color="RED"><b>public</b></font> <font color="RED"><b>void</b></font> imageFieldMerging<font color="BLUE"><b>(</b></font>ImageFieldMergingArgs args<font color="BLUE"><b>)</b></font> <font color="RED"><b>throws</b></font> Exception
<font color="BLUE"><b>{</b></font>
    <font color="GREEN"><i>// Do nothing.


Hope, this helps.

Best regards,