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

MethodDescription
execute(InputStream inputStream, OutputStream outputStream, int saveFormat, MailMergeOptions mailMergeOptions, System.Data.DataRow dataRow)
execute(InputStream inputStream, OutputStream outputStream, int saveFormat, MailMergeOptions mailMergeOptions, System.Data.DataTable dataTable)
execute(InputStream inputStream, OutputStream outputStream, int saveFormat, MailMergeOptions mailMergeOptions, String[] fieldNames, Object[] fieldValues)
execute(InputStream inputStream, OutputStream outputStream, int saveFormat, System.Data.DataRow dataRow)
execute(InputStream inputStream, OutputStream outputStream, int saveFormat, System.Data.DataTable dataTable)
execute(InputStream inputStream, OutputStream outputStream, int saveFormat, String[] fieldNames, Object[] fieldValues)
execute(String inputFileName, String outputFileName, System.Data.DataRow dataRow)Performs mail merge from a DataRow into the document.
execute(String inputFileName, String outputFileName, System.Data.DataTable dataTable)Performs mail merge from a DataTable into the document.
execute(String inputFileName, String outputFileName, int saveFormat, MailMergeOptions mailMergeOptions, System.Data.DataRow dataRow)
execute(String inputFileName, String outputFileName, int saveFormat, MailMergeOptions mailMergeOptions, System.Data.DataTable dataTable)
execute(String inputFileName, String outputFileName, int saveFormat, MailMergeOptions mailMergeOptions, String[] fieldNames, Object[] fieldValues)
execute(String inputFileName, String outputFileName, int saveFormat, System.Data.DataRow dataRow)
execute(String inputFileName, String outputFileName, int saveFormat, System.Data.DataTable dataTable)
execute(String inputFileName, String outputFileName, int saveFormat, String[] fieldNames, Object[] fieldValues)
execute(String inputFileName, String outputFileName, String[] fieldNames, Object[] fieldValues)Performs a mail merge operation for a single record.
executeWithRegions(InputStream inputStream, OutputStream outputStream, int saveFormat, MailMergeOptions mailMergeOptions, System.Data.DataSet dataSet)
executeWithRegions(InputStream inputStream, OutputStream outputStream, int saveFormat, MailMergeOptions mailMergeOptions, System.Data.DataTable dataTable)
executeWithRegions(InputStream inputStream, OutputStream outputStream, int saveFormat, System.Data.DataSet dataSet)
executeWithRegions(InputStream inputStream, OutputStream outputStream, int saveFormat, System.Data.DataTable dataTable)
executeWithRegions(String inputFileName, String outputFileName, System.Data.DataSet dataSet)Performs mail merge from a DataSet into a document with mail merge regions.
executeWithRegions(String inputFileName, String outputFileName, System.Data.DataTable dataTable)Performs mail merge from a DataTable into the document with mail merge regions.
executeWithRegions(String inputFileName, String outputFileName, int saveFormat, MailMergeOptions mailMergeOptions, System.Data.DataSet dataSet)
executeWithRegions(String inputFileName, String outputFileName, int saveFormat, MailMergeOptions mailMergeOptions, System.Data.DataTable dataTable)
executeWithRegions(String inputFileName, String outputFileName, int saveFormat, System.Data.DataSet dataSet)
executeWithRegions(String inputFileName, String outputFileName, int saveFormat, System.Data.DataTable dataTable)

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:

ParameterTypeDescription
inputStreamjava.io.InputStream
outputStreamjava.io.OutputStream
saveFormatint
mailMergeOptionsMailMergeOptions
dataRowDataRow

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:

ParameterTypeDescription
inputStreamjava.io.InputStream
outputStreamjava.io.OutputStream
saveFormatint
mailMergeOptionsMailMergeOptions
dataTableDataTable

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:

ParameterTypeDescription
inputStreamjava.io.InputStream
outputStreamjava.io.OutputStream
saveFormatint
mailMergeOptionsMailMergeOptions
fieldNamesjava.lang.String[]
fieldValuesjava.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:

ParameterTypeDescription
inputStreamjava.io.InputStream
outputStreamjava.io.OutputStream
saveFormatint
dataRowDataRow

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:

ParameterTypeDescription
inputStreamjava.io.InputStream
outputStreamjava.io.OutputStream
saveFormatint
dataTableDataTable

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:

ParameterTypeDescription
inputStreamjava.io.InputStream
outputStreamjava.io.OutputStream
saveFormatint
fieldNamesjava.lang.String[]
fieldValuesjava.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:

ParameterTypeDescription
inputFileNamejava.lang.StringThe input file name.
outputFileNamejava.lang.StringThe output file name.
dataRowDataRowRow 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:

ParameterTypeDescription
inputFileNamejava.lang.StringThe input file name.
outputFileNamejava.lang.StringThe output file name.
dataTableDataTableTable 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:

ParameterTypeDescription
inputFileNamejava.lang.String
outputFileNamejava.lang.String
saveFormatint
mailMergeOptionsMailMergeOptions
dataRowDataRow

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:

ParameterTypeDescription
inputFileNamejava.lang.String
outputFileNamejava.lang.String
saveFormatint
mailMergeOptionsMailMergeOptions
dataTableDataTable

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:

ParameterTypeDescription
inputFileNamejava.lang.String
outputFileNamejava.lang.String
saveFormatint
mailMergeOptionsMailMergeOptions
fieldNamesjava.lang.String[]
fieldValuesjava.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:

ParameterTypeDescription
inputFileNamejava.lang.String
outputFileNamejava.lang.String
saveFormatint
dataRowDataRow

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:

ParameterTypeDescription
inputFileNamejava.lang.String
outputFileNamejava.lang.String
saveFormatint
dataTableDataTable

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:

ParameterTypeDescription
inputFileNamejava.lang.String
outputFileNamejava.lang.String
saveFormatint
fieldNamesjava.lang.String[]
fieldValuesjava.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:

ParameterTypeDescription
inputFileNamejava.lang.StringThe input file name.
outputFileNamejava.lang.StringThe output file name.
fieldNamesjava.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.
fieldValuesjava.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:

ParameterTypeDescription
inputStreamjava.io.InputStream
outputStreamjava.io.OutputStream
saveFormatint
mailMergeOptionsMailMergeOptions
dataSetDataSet

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:

ParameterTypeDescription
inputStreamjava.io.InputStream
outputStreamjava.io.OutputStream
saveFormatint
mailMergeOptionsMailMergeOptions
dataTableDataTable

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:

ParameterTypeDescription
inputStreamjava.io.InputStream
outputStreamjava.io.OutputStream
saveFormatint
dataSetDataSet

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:

ParameterTypeDescription
inputStreamjava.io.InputStream
outputStreamjava.io.OutputStream
saveFormatint
dataTableDataTable

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:

ParameterTypeDescription
inputFileNamejava.lang.StringThe input file name.
outputFileNamejava.lang.StringThe output file name.
dataSetDataSetDataSet 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:

ParameterTypeDescription
inputFileNamejava.lang.StringThe input file name.
outputFileNamejava.lang.StringThe output file name.
dataTableDataTableData 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:

ParameterTypeDescription
inputFileNamejava.lang.String
outputFileNamejava.lang.String
saveFormatint
mailMergeOptionsMailMergeOptions
dataSetDataSet

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:

ParameterTypeDescription
inputFileNamejava.lang.String
outputFileNamejava.lang.String
saveFormatint
mailMergeOptionsMailMergeOptions
dataTableDataTable

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:

ParameterTypeDescription
inputFileNamejava.lang.String
outputFileNamejava.lang.String
saveFormatint
dataSetDataSet

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:

ParameterTypeDescription
inputFileNamejava.lang.String
outputFileNamejava.lang.String
saveFormatint
dataTableDataTable