public class MailMergeOptions
extends java.lang.Object
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, fieldNames, fieldValues, options);
| Constructor and Description |
|---|
MailMergeOptions()
Initializes a new instance of this class.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getCleanupOptions()
Gets a set of flags that specify what items should be removed during mail merge.
|
boolean |
getCleanupParagraphsWithPunctuationMarks()
Gets a value indicating whether paragraphs with punctuation marks are considered as empty and should be removed if the
MailMergeCleanupOptions.REMOVE_EMPTY_PARAGRAPHS option is specified. |
boolean |
getMergeDuplicateRegions()
Gets a value indicating whether all of the document mail merge regions with the name of a data source should be merged while executing of a mail merge with regions against the data source or just the first one.
|
boolean |
getMergeWholeDocument()
Gets a value indicating whether fields in whole document are updated while executing of a mail merge with regions.
|
boolean |
getPreserveUnusedTags()
Gets a value indicating whether the unused "mustache" tags should be preserved.
|
java.lang.String |
getRegionEndTag()
Gets a mail merge region end tag.
|
java.lang.String |
getRegionStartTag()
Gets a mail merge region start tag.
|
boolean |
getRestartListsAtEachSection()
Gets a value indicating whether lists are restarted at each section after executing of a mail merge.
|
boolean |
getRetainFirstSectionStart()
Gets a value indicating whether the section start of the first document section and its copies for subsequent data source rows are retained during mail merge or updated according to MS Word behaviour.
|
boolean |
getTrimWhitespaces()
Gets a value indicating whether trailing and leading whitespaces are trimmed from mail merge values.
|
boolean |
getUnconditionalMergeFieldsAndRegions()
Gets a value indicating whether merge fields and merge regions are merged regardless of the parent IF field's condition.
|
boolean |
getUseNonMergeFields()
When
true, specifies that in addition to MERGEFIELD fields, mail merge is performed into some other types of fields and also into "{{fieldName}}" tags. |
boolean |
getUseWholeParagraphAsRegion()
Gets a value indicating whether whole paragraph with TableStart or TableEnd field or particular range between TableStart and TableEnd fields should be included into mail merge region.
|
void |
setCleanupOptions(int value)
Sets a set of flags that specify what items should be removed during mail merge.
|
void |
setCleanupParagraphsWithPunctuationMarks(boolean value)
Sets a value indicating whether paragraphs with punctuation marks are considered as empty and should be removed if the
MailMergeCleanupOptions.REMOVE_EMPTY_PARAGRAPHS option is specified. |
void |
setMergeDuplicateRegions(boolean value)
Sets a value indicating whether all of the document mail merge regions with the name of a data source should be merged while executing of a mail merge with regions against the data source or just the first one.
|
void |
setMergeWholeDocument(boolean value)
Sets a value indicating whether fields in whole document are updated while executing of a mail merge with regions.
|
void |
setPreserveUnusedTags(boolean value)
Sets a value indicating whether the unused "mustache" tags should be preserved.
|
void |
setRegionEndTag(java.lang.String value)
Sets a mail merge region end tag.
|
void |
setRegionStartTag(java.lang.String value)
Sets a mail merge region start tag.
|
void |
setRestartListsAtEachSection(boolean value)
Sets a value indicating whether lists are restarted at each section after executing of a mail merge.
|
void |
setRetainFirstSectionStart(boolean value)
Sets a value indicating whether the section start of the first document section and its copies for subsequent data source rows are retained during mail merge or updated according to MS Word behaviour.
|
void |
setTrimWhitespaces(boolean value)
Sets a value indicating whether trailing and leading whitespaces are trimmed from mail merge values.
|
void |
setUnconditionalMergeFieldsAndRegions(boolean value)
Sets a value indicating whether merge fields and merge regions are merged regardless of the parent IF field's condition.
|
void |
setUseNonMergeFields(boolean value)
When
true, specifies that in addition to MERGEFIELD fields, mail merge is performed into some other types of fields and also into "{{fieldName}}" tags. |
void |
setUseWholeParagraphAsRegion(boolean value)
Sets a value indicating whether whole paragraph with TableStart or TableEnd field or particular range between TableStart and TableEnd fields should be included into mail merge region.
|
public MailMergeOptions()
public java.lang.String getRegionStartTag()
public void setRegionStartTag(java.lang.String value)
value - A mail merge region start tag.public java.lang.String getRegionEndTag()
public void setRegionEndTag(java.lang.String value)
value - A mail merge region end tag.public int getCleanupOptions()
MailMergeCleanupOptions constants.public void setCleanupOptions(int value)
value - A set of flags that specify what items should be removed during mail merge. The value must be a bitwise combination of MailMergeCleanupOptions constants.public boolean getCleanupParagraphsWithPunctuationMarks()
MailMergeCleanupOptions.REMOVE_EMPTY_PARAGRAPHS option is specified.
Remarks:
The default value is true.
Here is the complete list of cleanable punctuation marks:
MailMergeCleanupOptions.REMOVE_EMPTY_PARAGRAPHS option is specified.public void setCleanupParagraphsWithPunctuationMarks(boolean value)
MailMergeCleanupOptions.REMOVE_EMPTY_PARAGRAPHS option is specified.
Remarks:
The default value is true.
Here is the complete list of cleanable punctuation marks:
value - A value indicating whether paragraphs with punctuation marks are considered as empty and should be removed if the MailMergeCleanupOptions.REMOVE_EMPTY_PARAGRAPHS option is specified.public boolean getUseNonMergeFields()
true, specifies that in addition to MERGEFIELD fields, mail merge is performed into some other types of fields and also into "{{fieldName}}" tags.
Remarks:
Normally, mail merge is only performed into MERGEFIELD fields, but several customers had their reporting built using other fields and had many documents created this way. To simplify migration (and because this approach was independently used by several customers) the ability to mail merge into other fields was introduced.
When getUseNonMergeFields() / setUseNonMergeFields(boolean) is set to true, Aspose.Words will perform mail merge into the following fields:
MERGEFIELD FieldName
MACROBUTTON NOMACRO FieldName
IF 0 = 0 "{FieldName}" ""
Also, when getUseNonMergeFields() / setUseNonMergeFields(boolean) is set to true, Aspose.Words will perform mail merge into text tags "{{fieldName}}". These are not fields, but just text tags.
boolean value.public void setUseNonMergeFields(boolean value)
true, specifies that in addition to MERGEFIELD fields, mail merge is performed into some other types of fields and also into "{{fieldName}}" tags.
Remarks:
Normally, mail merge is only performed into MERGEFIELD fields, but several customers had their reporting built using other fields and had many documents created this way. To simplify migration (and because this approach was independently used by several customers) the ability to mail merge into other fields was introduced.
When getUseNonMergeFields() / setUseNonMergeFields(boolean) is set to true, Aspose.Words will perform mail merge into the following fields:
MERGEFIELD FieldName
MACROBUTTON NOMACRO FieldName
IF 0 = 0 "{FieldName}" ""
Also, when getUseNonMergeFields() / setUseNonMergeFields(boolean) is set to true, Aspose.Words will perform mail merge into text tags "{{fieldName}}". These are not fields, but just text tags.
value - The corresponding boolean value.public boolean getPreserveUnusedTags()
Remarks:
The default value is false.
getUseNonMergeFields(),
setUseNonMergeFields(boolean)public void setPreserveUnusedTags(boolean value)
Remarks:
The default value is false.
value - A value indicating whether the unused "mustache" tags should be preserved.getUseNonMergeFields(),
setUseNonMergeFields(boolean)public boolean getMergeDuplicateRegions()
Remarks:
The default value is false.
public void setMergeDuplicateRegions(boolean value)
Remarks:
The default value is false.
value - A value indicating whether all of the document mail merge regions with the name of a data source should be merged while executing of a mail merge with regions against the data source or just the first one.public boolean getMergeWholeDocument()
Remarks:
The default value is false.
public void setMergeWholeDocument(boolean value)
Remarks:
The default value is false.
value - A value indicating whether fields in whole document are updated while executing of a mail merge with regions.public boolean getUseWholeParagraphAsRegion()
Remarks:
The default value is true.
public void setUseWholeParagraphAsRegion(boolean value)
Remarks:
The default value is true.
value - A value indicating whether whole paragraph with TableStart or TableEnd field or particular range between TableStart and TableEnd fields should be included into mail merge region.public boolean getRestartListsAtEachSection()
Remarks:
The default value is true.
public void setRestartListsAtEachSection(boolean value)
Remarks:
The default value is true.
value - A value indicating whether lists are restarted at each section after executing of a mail merge.public boolean getTrimWhitespaces()
Remarks:
The default value is true.
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, fieldNames, fieldValues, options);
public void setTrimWhitespaces(boolean value)
Remarks:
The default value is true.
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, fieldNames, fieldValues, options);
value - A value indicating whether trailing and leading whitespaces are trimmed from mail merge values.public boolean getUnconditionalMergeFieldsAndRegions()
Remarks:
The default value is false.
public void setUnconditionalMergeFieldsAndRegions(boolean value)
Remarks:
The default value is false.
value - A value indicating whether merge fields and merge regions are merged regardless of the parent IF field's condition.public boolean getRetainFirstSectionStart()
Remarks:
The default value is true.
public void setRetainFirstSectionStart(boolean value)
Remarks:
The default value is true.
value - A value indicating whether the section start of the first document section and its copies for subsequent data source rows are retained during mail merge or updated according to MS Word behaviour.