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

Free Support Forum - aspose.com

Table mailmerge - Aspose.Words (java)

I’ve seen the table mailmerge examples in C# and VB (using the DataTable object – see example below), but would like to do something similar with Aspose.Words (Java). There does not seem to be a similarly ‘generic’ approach with Java – it seems we either have to write new classes or get the data into a ResultSet (the simplest approach we are using writes the data to a database and reads it back).

Is there anything comparable to this C# for Java:

// This example creates a table, but you would normally load table from a database. 
DataTable table = new DataTable("Test");
table.Columns.Add("CustomerName");
table.Columns.Add("Address");
table.Rows.Add(new object[] {"Thomas Hardy", "120 Hanover Sq., London"});
table.Rows.Add(new object[] {"Paolo Accorti", "Via Monte Bianco 34, Torino"});

// Field values from the table are inserted into the mail merge fields found in the document.
doc.MailMerge.Execute(table);

Hi
Thanks for your request. Unfortunately there is no simple analog of DataTable in java. So you should use ResultSet or IMailMergeDatasource. See the following links for more information:
https://reference.aspose.com/words/java/com.aspose.words/mailmerge/#executeWithRegions-com.aspose.words.net.System.Data.DataSet-

https://reference.aspose.com/words/net/aspose.words.mailmerging/imailmergedatasource/

Hope this helps.
Best regards.