java.lang.Object
com.aspose.words.OdsoFieldMapData
- All Implemented Interfaces:
- java.lang.Cloneable
public class OdsoFieldMapData
- extends java.lang.Object
Specifies how a column in the external data source shall be mapped to the predefined merge fields within the document.
Microsoft Word provides some predefined merge field names that it allows to insert into a document as MERGEFIELD or
use in the ADDRESSBLOCK or GREETINGLINE fields. The information specified in OdsoFieldMapData
allows to map one column in the external data source to a single predefined merge field.
Example:
Shows how to access the collection of data that maps data source columns to merge fields.
Document doc = new Document(getMyDir() + "Odso data.docx");
// This collection defines how columns from an external data source will be mapped to predefined MERGEFIELD,
// ADDRESSBLOCK and GREETINGLINE fields during a mail merge
OdsoFieldMapDataCollection dataCollection = doc.getMailMergeSettings().getOdso().getFieldMapDatas();
Assert.assertEquals(30, dataCollection.getCount());
int index = 0;
for (OdsoFieldMapData data : dataCollection) {
System.out.println(MessageFormat.format("Field map data index #{0}, type \"{1}\":", index++, data.getType()));
if (data.getType() != OdsoFieldMappingType.NULL) {
System.out.println(MessageFormat.format("\tColumn named {0}, number {1} in the data source mapped to merge field named {2}.", data.getName(), data.getColumn(), data.getMappedName()));
} else {
System.out.println("\tNo valid column to field mapping data present.");
}
}
// Elements of the collection can be cloned
Assert.assertNotEquals(dataCollection.get(0), dataCollection.get(0).deepClone());
// The collection can have individual entries removed or be cleared like this
dataCollection.removeAt(0);
dataCollection.clear();
- See Also:
- OdsoFieldMapDataCollection, Odso
Property Getters/Setters Summary |
int | getColumn() | |
void | setColumn(int value) | |
|
Specifies the zero-based index of the column within an external data source which shall be
mapped to the local name of a specific MERGEFIELD field.
The default value is 0.
|
java.lang.String | getMappedName() | |
void | setMappedName(java.lang.String value) | |
|
Specifies the predefined merge field name which shall be mapped to the column number
specified by the Column property within this field mapping.
The default value is an empty string.
|
java.lang.String | getName() | |
void | setName(java.lang.String value) | |
|
Specifies the column name within an external data source for the column whose
index is specified by the Column property.
The default value is an empty string.
|
int | getType() | |
void | setType(int value) | |
|
Specifies if a given mail merge field has been mapped to a column in the given external data source or not.
The default value is OdsoFieldMappingType.DEFAULT.
The value of the property is OdsoFieldMappingType integer constant. |
OdsoFieldMapData
public OdsoFieldMapData()
-
Property Getters/Setters Detail |
getColumn/setColumn | |
public int getColumn() / public void setColumn(int value)
|
-
Specifies the zero-based index of the column within an external data source which shall be
mapped to the local name of a specific MERGEFIELD field.
The default value is 0.
Example:
Shows how to access the collection of data that maps data source columns to merge fields.
Document doc = new Document(getMyDir() + "Odso data.docx");
// This collection defines how columns from an external data source will be mapped to predefined MERGEFIELD,
// ADDRESSBLOCK and GREETINGLINE fields during a mail merge
OdsoFieldMapDataCollection dataCollection = doc.getMailMergeSettings().getOdso().getFieldMapDatas();
Assert.assertEquals(30, dataCollection.getCount());
int index = 0;
for (OdsoFieldMapData data : dataCollection) {
System.out.println(MessageFormat.format("Field map data index #{0}, type \"{1}\":", index++, data.getType()));
if (data.getType() != OdsoFieldMappingType.NULL) {
System.out.println(MessageFormat.format("\tColumn named {0}, number {1} in the data source mapped to merge field named {2}.", data.getName(), data.getColumn(), data.getMappedName()));
} else {
System.out.println("\tNo valid column to field mapping data present.");
}
}
// Elements of the collection can be cloned
Assert.assertNotEquals(dataCollection.get(0), dataCollection.get(0).deepClone());
// The collection can have individual entries removed or be cleared like this
dataCollection.removeAt(0);
dataCollection.clear();
getMappedName/setMappedName | |
public java.lang.String getMappedName() / public void setMappedName(java.lang.String value)
|
-
Specifies the predefined merge field name which shall be mapped to the column number
specified by the Column property within this field mapping.
The default value is an empty string.
Example:
Shows how to access the collection of data that maps data source columns to merge fields.
Document doc = new Document(getMyDir() + "Odso data.docx");
// This collection defines how columns from an external data source will be mapped to predefined MERGEFIELD,
// ADDRESSBLOCK and GREETINGLINE fields during a mail merge
OdsoFieldMapDataCollection dataCollection = doc.getMailMergeSettings().getOdso().getFieldMapDatas();
Assert.assertEquals(30, dataCollection.getCount());
int index = 0;
for (OdsoFieldMapData data : dataCollection) {
System.out.println(MessageFormat.format("Field map data index #{0}, type \"{1}\":", index++, data.getType()));
if (data.getType() != OdsoFieldMappingType.NULL) {
System.out.println(MessageFormat.format("\tColumn named {0}, number {1} in the data source mapped to merge field named {2}.", data.getName(), data.getColumn(), data.getMappedName()));
} else {
System.out.println("\tNo valid column to field mapping data present.");
}
}
// Elements of the collection can be cloned
Assert.assertNotEquals(dataCollection.get(0), dataCollection.get(0).deepClone());
// The collection can have individual entries removed or be cleared like this
dataCollection.removeAt(0);
dataCollection.clear();
getName/setName | |
public java.lang.String getName() / public void setName(java.lang.String value)
|
-
Specifies the column name within an external data source for the column whose
index is specified by the Column property.
The default value is an empty string.
Example:
Shows how to access the collection of data that maps data source columns to merge fields.
Document doc = new Document(getMyDir() + "Odso data.docx");
// This collection defines how columns from an external data source will be mapped to predefined MERGEFIELD,
// ADDRESSBLOCK and GREETINGLINE fields during a mail merge
OdsoFieldMapDataCollection dataCollection = doc.getMailMergeSettings().getOdso().getFieldMapDatas();
Assert.assertEquals(30, dataCollection.getCount());
int index = 0;
for (OdsoFieldMapData data : dataCollection) {
System.out.println(MessageFormat.format("Field map data index #{0}, type \"{1}\":", index++, data.getType()));
if (data.getType() != OdsoFieldMappingType.NULL) {
System.out.println(MessageFormat.format("\tColumn named {0}, number {1} in the data source mapped to merge field named {2}.", data.getName(), data.getColumn(), data.getMappedName()));
} else {
System.out.println("\tNo valid column to field mapping data present.");
}
}
// Elements of the collection can be cloned
Assert.assertNotEquals(dataCollection.get(0), dataCollection.get(0).deepClone());
// The collection can have individual entries removed or be cleared like this
dataCollection.removeAt(0);
dataCollection.clear();
getType/setType | |
public int getType() / public void setType(int value)
|
-
Specifies if a given mail merge field has been mapped to a column in the given external data source or not.
The default value is OdsoFieldMappingType.DEFAULT.
The value of the property is OdsoFieldMappingType integer constant.
Example:
Shows how to access the collection of data that maps data source columns to merge fields.
Document doc = new Document(getMyDir() + "Odso data.docx");
// This collection defines how columns from an external data source will be mapped to predefined MERGEFIELD,
// ADDRESSBLOCK and GREETINGLINE fields during a mail merge
OdsoFieldMapDataCollection dataCollection = doc.getMailMergeSettings().getOdso().getFieldMapDatas();
Assert.assertEquals(30, dataCollection.getCount());
int index = 0;
for (OdsoFieldMapData data : dataCollection) {
System.out.println(MessageFormat.format("Field map data index #{0}, type \"{1}\":", index++, data.getType()));
if (data.getType() != OdsoFieldMappingType.NULL) {
System.out.println(MessageFormat.format("\tColumn named {0}, number {1} in the data source mapped to merge field named {2}.", data.getName(), data.getColumn(), data.getMappedName()));
} else {
System.out.println("\tNo valid column to field mapping data present.");
}
}
// Elements of the collection can be cloned
Assert.assertNotEquals(dataCollection.get(0), dataCollection.get(0).deepClone());
// The collection can have individual entries removed or be cleared like this
dataCollection.removeAt(0);
dataCollection.clear();
-
Returns a deep clone of this object.
Example:
Shows how to access the collection of data that maps data source columns to merge fields.
Document doc = new Document(getMyDir() + "Odso data.docx");
// This collection defines how columns from an external data source will be mapped to predefined MERGEFIELD,
// ADDRESSBLOCK and GREETINGLINE fields during a mail merge
OdsoFieldMapDataCollection dataCollection = doc.getMailMergeSettings().getOdso().getFieldMapDatas();
Assert.assertEquals(30, dataCollection.getCount());
int index = 0;
for (OdsoFieldMapData data : dataCollection) {
System.out.println(MessageFormat.format("Field map data index #{0}, type \"{1}\":", index++, data.getType()));
if (data.getType() != OdsoFieldMappingType.NULL) {
System.out.println(MessageFormat.format("\tColumn named {0}, number {1} in the data source mapped to merge field named {2}.", data.getName(), data.getColumn(), data.getMappedName()));
} else {
System.out.println("\tNo valid column to field mapping data present.");
}
}
// Elements of the collection can be cloned
Assert.assertNotEquals(dataCollection.get(0), dataCollection.get(0).deepClone());
// The collection can have individual entries removed or be cleared like this
dataCollection.removeAt(0);
dataCollection.clear();
See Also:
Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
Aspose.Words Support Forum - our preferred method of support.