MailMerger
Inheritance: java.lang.Object
public class MailMerger
Provides methods intended to fill template with data using simple mail merge and mail merge with regions operations.
Methods
execute(InputStream inputStream, OutputStream outputStream, int saveFormat, MailMergeOptions mailMergeOptions, System.Data.DataRow dataRow)
public static void execute(InputStream inputStream, OutputStream outputStream, int saveFormat, MailMergeOptions mailMergeOptions, System.Data.DataRow dataRow)
Parameters:
Parameter | Type | Description |
---|---|---|
inputStream | java.io.InputStream | |
outputStream | java.io.OutputStream | |
saveFormat | int | |
mailMergeOptions | MailMergeOptions | |
dataRow | DataRow |
execute(InputStream inputStream, OutputStream outputStream, int saveFormat, MailMergeOptions mailMergeOptions, System.Data.DataTable dataTable)
public static void execute(InputStream inputStream, OutputStream outputStream, int saveFormat, MailMergeOptions mailMergeOptions, System.Data.DataTable dataTable)
Parameters:
Parameter | Type | Description |
---|---|---|
inputStream | java.io.InputStream | |
outputStream | java.io.OutputStream | |
saveFormat | int | |
mailMergeOptions | MailMergeOptions | |
dataTable | DataTable |
execute(InputStream inputStream, OutputStream outputStream, int saveFormat, MailMergeOptions mailMergeOptions, String[] fieldNames, Object[] fieldValues)
public static void execute(InputStream inputStream, OutputStream outputStream, int saveFormat, MailMergeOptions mailMergeOptions, String[] fieldNames, Object[] fieldValues)
Parameters:
Parameter | Type | Description |
---|---|---|
inputStream | java.io.InputStream | |
outputStream | java.io.OutputStream | |
saveFormat | int | |
mailMergeOptions | MailMergeOptions | |
fieldNames | java.lang.String[] | |
fieldValues | java.lang.Object[] |
execute(InputStream inputStream, OutputStream outputStream, int saveFormat, System.Data.DataRow dataRow)
public static void execute(InputStream inputStream, OutputStream outputStream, int saveFormat, System.Data.DataRow dataRow)
Parameters:
Parameter | Type | Description |
---|---|---|
inputStream | java.io.InputStream | |
outputStream | java.io.OutputStream | |
saveFormat | int | |
dataRow | DataRow |
execute(InputStream inputStream, OutputStream outputStream, int saveFormat, System.Data.DataTable dataTable)
public static void execute(InputStream inputStream, OutputStream outputStream, int saveFormat, System.Data.DataTable dataTable)
Parameters:
Parameter | Type | Description |
---|---|---|
inputStream | java.io.InputStream | |
outputStream | java.io.OutputStream | |
saveFormat | int | |
dataTable | DataTable |
execute(InputStream inputStream, OutputStream outputStream, int saveFormat, String[] fieldNames, Object[] fieldValues)
public static void execute(InputStream inputStream, OutputStream outputStream, int saveFormat, String[] fieldNames, Object[] fieldValues)
Parameters:
Parameter | Type | Description |
---|---|---|
inputStream | java.io.InputStream | |
outputStream | java.io.OutputStream | |
saveFormat | int | |
fieldNames | java.lang.String[] | |
fieldValues | java.lang.Object[] |
execute(String inputFileName, String outputFileName, System.Data.DataRow dataRow)
public static void execute(String inputFileName, String outputFileName, System.Data.DataRow dataRow)
Performs mail merge from a DataRow into the document.
Examples:
Shows how to do mail merge operation from a DataRow.
// There is a several ways to do mail merge operation from a DataRow:
String doc = getMyDir() + "Mail merge.doc";
DataTable dataTable = new DataTable();
dataTable.getColumns().add("FirstName");
dataTable.getColumns().add("Location");
dataTable.getColumns().add("SpecialCharsInName()");
dataTable.getRows().add(new String[] { "James Bond", "London", "Classified" });
DataRow dataRow = dataTable.getRows().get(0);
MailMerger.execute(doc, getArtifactsDir() + "LowCode.MailMergeDataRow.1.docx", dataRow);
MailMerger.execute(doc, getArtifactsDir() + "LowCode.MailMergeDataRow.2.docx", SaveFormat.DOCX, dataRow);
MailMergeOptions options = new MailMergeOptions();
options.setTrimWhitespaces(true);
MailMerger.execute(doc, getArtifactsDir() + "LowCode.MailMergeDataRow.3.docx", SaveFormat.DOCX, options, dataRow);
Parameters:
Parameter | Type | Description |
---|---|---|
inputFileName | java.lang.String | The input file name. |
outputFileName | java.lang.String | The output file name. |
dataRow | DataRow | Row that contains data to be inserted into mail merge fields. Field names are not case sensitive. If a field name that is not found in the document is encountered, it is ignored. |
execute(String inputFileName, String outputFileName, System.Data.DataTable dataTable)
public static void execute(String inputFileName, String outputFileName, System.Data.DataTable dataTable)
Performs mail merge from a DataTable into the document.
Examples:
Shows how to do mail merge operation from a DataTable.
// There is a several ways to do mail merge operation from a DataTable:
String doc = getMyDir() + "Mail merge.doc";
DataTable dataTable = new DataTable();
dataTable.getColumns().add("FirstName");
dataTable.getColumns().add("Location");
dataTable.getColumns().add("SpecialCharsInName()");
dataTable.getRows().add(new String[]{"James Bond", "London", "Classified"});
MailMerger.execute(doc, getArtifactsDir() + "LowCode.MailMergeDataTable.1.docx", dataTable);
MailMerger.execute(doc, getArtifactsDir() + "LowCode.MailMergeDataTable.2.docx", SaveFormat.DOCX, dataTable);
MailMergeOptions options = new MailMergeOptions();
options.setTrimWhitespaces(true);
MailMerger.execute(doc, getArtifactsDir() + "LowCode.MailMergeDataTable.3.docx", SaveFormat.DOCX, options, dataTable);
Parameters:
Parameter | Type | Description |
---|---|---|
inputFileName | java.lang.String | The input file name. |
outputFileName | java.lang.String | The output file name. |
dataTable | DataTable | Table that contains data to be inserted into mail merge fields. Field names are not case sensitive. If a field name that is not found in the document is encountered, it is ignored. |
execute(String inputFileName, String outputFileName, int saveFormat, MailMergeOptions mailMergeOptions, System.Data.DataRow dataRow)
public static void execute(String inputFileName, String outputFileName, int saveFormat, MailMergeOptions mailMergeOptions, System.Data.DataRow dataRow)
Parameters:
Parameter | Type | Description |
---|---|---|
inputFileName | java.lang.String | |
outputFileName | java.lang.String | |
saveFormat | int | |
mailMergeOptions | MailMergeOptions | |
dataRow | DataRow |
execute(String inputFileName, String outputFileName, int saveFormat, MailMergeOptions mailMergeOptions, System.Data.DataTable dataTable)
public static void execute(String inputFileName, String outputFileName, int saveFormat, MailMergeOptions mailMergeOptions, System.Data.DataTable dataTable)
Parameters:
Parameter | Type | Description |
---|---|---|
inputFileName | java.lang.String | |
outputFileName | java.lang.String | |
saveFormat | int | |
mailMergeOptions | MailMergeOptions | |
dataTable | DataTable |
execute(String inputFileName, String outputFileName, int saveFormat, MailMergeOptions mailMergeOptions, String[] fieldNames, Object[] fieldValues)
public static void execute(String inputFileName, String outputFileName, int saveFormat, MailMergeOptions mailMergeOptions, String[] fieldNames, Object[] fieldValues)
Parameters:
Parameter | Type | Description |
---|---|---|
inputFileName | java.lang.String | |
outputFileName | java.lang.String | |
saveFormat | int | |
mailMergeOptions | MailMergeOptions | |
fieldNames | java.lang.String[] | |
fieldValues | java.lang.Object[] |
execute(String inputFileName, String outputFileName, int saveFormat, System.Data.DataRow dataRow)
public static void execute(String inputFileName, String outputFileName, int saveFormat, System.Data.DataRow dataRow)
Parameters:
Parameter | Type | Description |
---|---|---|
inputFileName | java.lang.String | |
outputFileName | java.lang.String | |
saveFormat | int | |
dataRow | DataRow |
execute(String inputFileName, String outputFileName, int saveFormat, System.Data.DataTable dataTable)
public static void execute(String inputFileName, String outputFileName, int saveFormat, System.Data.DataTable dataTable)
Parameters:
Parameter | Type | Description |
---|---|---|
inputFileName | java.lang.String | |
outputFileName | java.lang.String | |
saveFormat | int | |
dataTable | DataTable |
execute(String inputFileName, String outputFileName, int saveFormat, String[] fieldNames, Object[] fieldValues)
public static void execute(String inputFileName, String outputFileName, int saveFormat, String[] fieldNames, Object[] fieldValues)
Parameters:
Parameter | Type | Description |
---|---|---|
inputFileName | java.lang.String | |
outputFileName | java.lang.String | |
saveFormat | int | |
fieldNames | java.lang.String[] | |
fieldValues | java.lang.Object[] |
execute(String inputFileName, String outputFileName, String[] fieldNames, Object[] fieldValues)
public static void execute(String inputFileName, String outputFileName, String[] fieldNames, Object[] fieldValues)
Performs a mail merge operation for a single record.
Examples:
Shows how to do mail merge operation for a single record.
// There is a several ways to do mail merge operation:
String doc = getMyDir() + "Mail merge.doc";
String[] fieldNames = new String[] { "FirstName", "Location", "SpecialCharsInName()" };
String[] fieldValues = new String[] { "James Bond", "London", "Classified" };
MailMerger.execute(doc, getArtifactsDir() + "LowCode.MailMerge.1.docx", fieldNames, fieldValues);
MailMerger.execute(doc, getArtifactsDir() + "LowCode.MailMerge.2.docx", SaveFormat.DOCX, fieldNames, fieldValues);
MailMergeOptions options = new MailMergeOptions();
options.setTrimWhitespaces(true);
MailMerger.execute(doc, getArtifactsDir() + "LowCode.MailMerge.3.docx", SaveFormat.DOCX, options, fieldNames, fieldValues);
Parameters:
Parameter | Type | Description |
---|---|---|
inputFileName | java.lang.String | The input file name. |
outputFileName | java.lang.String | The output file name. |
fieldNames | java.lang.String[] | Array of merge field names. Field names are not case sensitive. If a field name that is not found in the document is encountered, it is ignored. |
fieldValues | java.lang.Object[] | Array of values to be inserted into the merge fields. Number of elements in this array must be the same as the number of elements in fieldNames. |
executeWithRegions(InputStream inputStream, OutputStream outputStream, int saveFormat, MailMergeOptions mailMergeOptions, System.Data.DataSet dataSet)
public static void executeWithRegions(InputStream inputStream, OutputStream outputStream, int saveFormat, MailMergeOptions mailMergeOptions, System.Data.DataSet dataSet)
Parameters:
Parameter | Type | Description |
---|---|---|
inputStream | java.io.InputStream | |
outputStream | java.io.OutputStream | |
saveFormat | int | |
mailMergeOptions | MailMergeOptions | |
dataSet | DataSet |
executeWithRegions(InputStream inputStream, OutputStream outputStream, int saveFormat, MailMergeOptions mailMergeOptions, System.Data.DataTable dataTable)
public static void executeWithRegions(InputStream inputStream, OutputStream outputStream, int saveFormat, MailMergeOptions mailMergeOptions, System.Data.DataTable dataTable)
Parameters:
Parameter | Type | Description |
---|---|---|
inputStream | java.io.InputStream | |
outputStream | java.io.OutputStream | |
saveFormat | int | |
mailMergeOptions | MailMergeOptions | |
dataTable | DataTable |
executeWithRegions(InputStream inputStream, OutputStream outputStream, int saveFormat, System.Data.DataSet dataSet)
public static void executeWithRegions(InputStream inputStream, OutputStream outputStream, int saveFormat, System.Data.DataSet dataSet)
Parameters:
Parameter | Type | Description |
---|---|---|
inputStream | java.io.InputStream | |
outputStream | java.io.OutputStream | |
saveFormat | int | |
dataSet | DataSet |
executeWithRegions(InputStream inputStream, OutputStream outputStream, int saveFormat, System.Data.DataTable dataTable)
public static void executeWithRegions(InputStream inputStream, OutputStream outputStream, int saveFormat, System.Data.DataTable dataTable)
Parameters:
Parameter | Type | Description |
---|---|---|
inputStream | java.io.InputStream | |
outputStream | java.io.OutputStream | |
saveFormat | int | |
dataTable | DataTable |
executeWithRegions(String inputFileName, String outputFileName, System.Data.DataSet dataSet)
public static void executeWithRegions(String inputFileName, String outputFileName, System.Data.DataSet dataSet)
Performs mail merge from a DataSet into a document with mail merge regions.
Examples:
Shows how to do mail merge with regions operation from a DataSet.
// There is a several ways to do mail merge with regions operation from a DataSet:
String doc = getMyDir() + "Mail merge with regions data set.docx";
DataTable tableCustomers = new DataTable("Customers");
tableCustomers.getColumns().add("CustomerID");
tableCustomers.getColumns().add("CustomerName");
tableCustomers.getRows().add(new Object[] { 1, "John Doe" });
tableCustomers.getRows().add(new Object[] { 2, "Jane Doe" });
DataTable tableOrders = new DataTable("Orders");
tableOrders.getColumns().add("CustomerID");
tableOrders.getColumns().add("ItemName");
tableOrders.getColumns().add("Quantity");
tableOrders.getRows().add(new Object[] { 1, "Hawaiian", 2 });
tableOrders.getRows().add(new Object[] { 2, "Pepperoni", 1 });
tableOrders.getRows().add(new Object[] { 2, "Chicago", 1 });
DataSet dataSet = new DataSet();
dataSet.getTables().add(tableCustomers);
dataSet.getTables().add(tableOrders);
dataSet.getRelations().add(tableCustomers.getColumns().get("CustomerID"), tableOrders.getColumns().get("CustomerID"));
MailMerger.executeWithRegions(doc, getArtifactsDir() + "LowCode.MailMergeWithRegionsDataSet.1.docx", dataSet);
MailMerger.executeWithRegions(doc, getArtifactsDir() + "LowCode.MailMergeWithRegionsDataSet.2.docx", SaveFormat.DOCX, dataSet);
MailMergeOptions options = new MailMergeOptions();
options.setTrimWhitespaces(true);
MailMerger.executeWithRegions(doc, getArtifactsDir() + "LowCode.MailMergeWithRegionsDataSet.3.docx", SaveFormat.DOCX, options, dataSet);
Parameters:
Parameter | Type | Description |
---|---|---|
inputFileName | java.lang.String | The input file name. |
outputFileName | java.lang.String | The output file name. |
dataSet | DataSet | DataSet that contains data to be inserted into mail merge fields. |
executeWithRegions(String inputFileName, String outputFileName, System.Data.DataTable dataTable)
public static void executeWithRegions(String inputFileName, String outputFileName, System.Data.DataTable dataTable)
Performs mail merge from a DataTable into the document with mail merge regions.
Examples:
Shows how to do mail merge with regions operation from a DataTable.
// There is a several ways to do mail merge with regions operation from a DataTable:
String doc = getMyDir() + "Mail merge with regions.docx";
DataTable dataTable = new DataTable("MyTable");
dataTable.getColumns().add("FirstName");
dataTable.getColumns().add("LastName");
dataTable.getRows().add(new Object[] { "John", "Doe" });
dataTable.getRows().add(new Object[] { "", "" });
dataTable.getRows().add(new Object[] { "Jane", "Doe" });
MailMerger.executeWithRegions(doc, getArtifactsDir() + "LowCode.MailMergeWithRegionsDataTable.1.docx", dataTable);
MailMerger.executeWithRegions(doc, getArtifactsDir() + "LowCode.MailMergeWithRegionsDataTable.2.docx", SaveFormat.DOCX, dataTable);
MailMergeOptions options = new MailMergeOptions();
options.setTrimWhitespaces(true);
MailMerger.executeWithRegions(doc, getArtifactsDir() + "LowCode.MailMergeWithRegionsDataTable.3.docx", SaveFormat.DOCX, options, dataTable);
Parameters:
Parameter | Type | Description |
---|---|---|
inputFileName | java.lang.String | The input file name. |
outputFileName | java.lang.String | The output file name. |
dataTable | DataTable | Data source for the mail merge operation. The table must have its TableName property set. |
executeWithRegions(String inputFileName, String outputFileName, int saveFormat, MailMergeOptions mailMergeOptions, System.Data.DataSet dataSet)
public static void executeWithRegions(String inputFileName, String outputFileName, int saveFormat, MailMergeOptions mailMergeOptions, System.Data.DataSet dataSet)
Parameters:
Parameter | Type | Description |
---|---|---|
inputFileName | java.lang.String | |
outputFileName | java.lang.String | |
saveFormat | int | |
mailMergeOptions | MailMergeOptions | |
dataSet | DataSet |
executeWithRegions(String inputFileName, String outputFileName, int saveFormat, MailMergeOptions mailMergeOptions, System.Data.DataTable dataTable)
public static void executeWithRegions(String inputFileName, String outputFileName, int saveFormat, MailMergeOptions mailMergeOptions, System.Data.DataTable dataTable)
Parameters:
Parameter | Type | Description |
---|---|---|
inputFileName | java.lang.String | |
outputFileName | java.lang.String | |
saveFormat | int | |
mailMergeOptions | MailMergeOptions | |
dataTable | DataTable |
executeWithRegions(String inputFileName, String outputFileName, int saveFormat, System.Data.DataSet dataSet)
public static void executeWithRegions(String inputFileName, String outputFileName, int saveFormat, System.Data.DataSet dataSet)
Parameters:
Parameter | Type | Description |
---|---|---|
inputFileName | java.lang.String | |
outputFileName | java.lang.String | |
saveFormat | int | |
dataSet | DataSet |
executeWithRegions(String inputFileName, String outputFileName, int saveFormat, System.Data.DataTable dataTable)
public static void executeWithRegions(String inputFileName, String outputFileName, int saveFormat, System.Data.DataTable dataTable)
Parameters:
Parameter | Type | Description |
---|---|---|
inputFileName | java.lang.String | |
outputFileName | java.lang.String | |
saveFormat | int | |
dataTable | DataTable |