java.lang.Object
com.aspose.words.MailMergeCheckErrors
public class MailMergeCheckErrors
- extends java.lang.Object
Utility class containing constants.
Specifies how Microsoft Word will report errors detected during mail merge.
Example:
Shows how to execute an Office Data Source Object mail merge with MailMergeSettings.
// We'll create a simple document that will act as a destination for mail merge data
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write("Dear ");
builder.insertField("MERGEFIELD FirstName", "<FirstName>");
builder.write(" ");
builder.insertField("MERGEFIELD LastName", "<LastName>");
builder.writeln(": ");
builder.insertField("MERGEFIELD Message", "<Message>");
// Also we'll need a data source, in this case it will be an ASCII text file
// We can use any character we want as a delimiter, in this case we'll choose '|'
// The delimiter character is selected in the ODSO settings of mail merge settings
String[] lines = {"FirstName|LastName|Message",
"John|Doe|Hello! This message was created with Aspose Words mail merge."};
String dataSrcFilename = getArtifactsDir() + "Document.MailMergeSettings.DataSource.txt";
Files.write(Paths.get(dataSrcFilename),
(lines + System.lineSeparator()).getBytes(UTF_8),
new StandardOpenOption[]{StandardOpenOption.CREATE, StandardOpenOption.APPEND});
// Set the data source, query and other things
MailMergeSettings settings = doc.getMailMergeSettings();
settings.setMainDocumentType(MailMergeMainDocumentType.MAILING_LABELS);
settings.setCheckErrors(MailMergeCheckErrors.SIMULATE);
settings.setDataType(MailMergeDataType.NATIVE);
settings.setDataSource(dataSrcFilename);
settings.setQuery("SELECT * FROM " + doc.getMailMergeSettings().getDataSource());
settings.setLinkToQuery(true);
settings.setViewMergedData(true);
Assert.assertEquals(settings.getDestination(), MailMergeDestination.DEFAULT);
Assert.assertFalse(settings.getDoNotSupressBlankLines());
// Office Data Source Object settings
Odso odso = settings.getOdso();
odso.setDataSource(dataSrcFilename);
odso.setDataSourceType(OdsoDataSourceType.TEXT);
odso.setColumnDelimiter('|');
odso.setFirstRowContainsColumnNames(true);
// ODSO/MailMergeSettings objects can also be cloned
Assert.assertNotSame(odso, odso.deepClone());
Assert.assertNotSame(settings, settings.deepClone());
// The mail merge will be performed when this document is opened
doc.save(getArtifactsDir() + "Document.MailMergeSettings.docx");
- See Also:
- MailMergeSettings.CheckErrors
Field Summary |
static final int | SIMULATE = 1 | |
Simulate the merge and report errors in a new document.
|
static final int | PAUSE_ON_ERROR = 2 | |
Complete the merge and pause to report errors.
|
static final int | COLLECT_ERRORS = 3 | |
Complete the merge and report errors in a new document.
|
static final int | DEFAULT = 2 | |
Equals to the PAUSE_ON_ERROR value.
|
SIMULATE = 1 | |
public static final int SIMULATE |
-
Simulate the merge and report errors in a new document.
PAUSE_ON_ERROR = 2 | |
public static final int PAUSE_ON_ERROR |
-
Complete the merge and pause to report errors.
COLLECT_ERRORS = 3 | |
public static final int COLLECT_ERRORS |
-
Complete the merge and report errors in a new document.
DEFAULT = 2 | |
public static final int DEFAULT |
-
Equals to the PAUSE_ON_ERROR value.
See Also:
Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
Aspose.Words Support Forum - our preferred method of support.