-
Notifications
You must be signed in to change notification settings - Fork 206
/
WorkingWithXmlData.java
60 lines (46 loc) · 2.04 KB
/
WorkingWithXmlData.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package DocsExamples.Mail_Merge_And_Reporting;
import DocsExamples.DocsExamplesBase;
import com.aspose.words.Document;
import com.aspose.words.net.System.Data.DataSet;
import org.testng.annotations.Test;
@Test
public class WorkingWithXmlData extends DocsExamplesBase
{
@Test
public void xmlMailMerge() throws Exception
{
//ExStart:XmlMailMerge
DataSet customersDs = new DataSet();
customersDs.readXml(getMyDir() + "Mail merge data - Customers.xml");
Document doc = new Document(getMyDir() + "Mail merge destinations - Registration complete.docx");
doc.getMailMerge().execute(customersDs.getTables().get("Customer"));
doc.save(getArtifactsDir() + "WorkingWithXmlData.XmlMailMerge.docx");
//ExEnd:XmlMailMerge
}
@Test
public void nestedMailMerge() throws Exception
{
//ExStart:NestedMailMerge
// The Datatable.TableNames and the DataSet.Relations are defined implicitly by .NET through ReadXml.
DataSet pizzaDs = new DataSet();
pizzaDs.readXml(getMyDir() + "Mail merge data - Orders.xml");
Document doc = new Document(getMyDir() + "Mail merge destinations - Invoice.docx");
// Trim trailing and leading whitespaces mail merge values.
doc.getMailMerge().setTrimWhitespaces(false);
doc.getMailMerge().executeWithRegions(pizzaDs);
doc.save(getArtifactsDir() + "WorkingWithXmlData.NestedMailMerge.docx");
//ExEnd:NestedMailMerge
}
@Test
public void mustacheSyntaxUsingDataSet() throws Exception
{
//ExStart:MailMergeUsingMustacheSyntax
DataSet ds = new DataSet();
ds.readXml(getMyDir() + "Mail merge data - Vendors.xml");
Document doc = new Document(getMyDir() + "Mail merge destinations - Vendor.docx");
doc.getMailMerge().setUseNonMergeFields(true);
doc.getMailMerge().executeWithRegions(ds);
doc.save(getArtifactsDir() + "WorkingWithXmlData.MustacheSyntaxUsingDataSet.docx");
//ExEnd:MailMergeUsingMustacheSyntax
}
}