com.aspose.words

Class OdsoDataSourceType

  • java.lang.Object
    • com.aspose.words.OdsoDataSourceType
public class OdsoDataSourceType 
extends java.lang.Object

Utility class containing constants. Specifies the type of the external data source to be connected to as part of the ODSO connection information.

The OOXML specification is very vague for this enum. I guess it might correspond to the WdMergeSubType enumeration http://msdn.microsoft.com/en-us/library/bb237801.aspx.

Example:

Shows how to execute a 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."};
Files.write(Paths.get(getArtifactsDir() + "Document.Lines.txt"),
        (lines + System.lineSeparator()).getBytes(UTF_8),
        new StandardOpenOption[]{StandardOpenOption.CREATE, StandardOpenOption.APPEND});

// Set the data source, query and other things
MailMergeSettings mailMergeSettings = doc.getMailMergeSettings();
mailMergeSettings.setMainDocumentType(MailMergeMainDocumentType.MAILING_LABELS);
mailMergeSettings.setDataType(MailMergeDataType.NATIVE);
mailMergeSettings.setDataSource(getArtifactsDir() + "Document.Lines.txt");
mailMergeSettings.setQuery("SELECT * FROM " + doc.getMailMergeSettings().getDataSource());
mailMergeSettings.setLinkToQuery(true);
mailMergeSettings.setViewMergedData(true);

// Office Data Source Object settings
Odso odso = mailMergeSettings.getOdso();
odso.setDataSource(getArtifactsDir() + "Document.Lines.txt");
odso.setDataSourceType(OdsoDataSourceType.TEXT);
odso.setColumnDelimiter('|');
odso.setDataSource(getArtifactsDir() + "Document.Lines.txt");
odso.setFirstRowContainsColumnNames(true);

// ODSO objects can also be cloned
Assert.assertNotSame(odso, odso.deepClone());

// The mail merge will be performed when this document is opened
doc.save(getArtifactsDir() + "Document.MailMergeSettings.docx");
See Also:
Odso.DataSourceType

Field Summary
static final intTEXT = 0
Specifies that a given document has been connected to a text file. Possibly wdMergeSubTypeOther.
static final intDATABASE = 1
Specifies that a given document has been connected to a database. Possibly wdMergeSubTypeAccess.
static final intADDRESS_BOOK = 2
Specifies that a given document has been connected to an address book of contacts. Possibly wdMergeSubTypeOAL.
static final intDOCUMENT_1 = 3
Specifies that a given document has been connected to another document format supported by the producing application. Possibly wdMergeSubTypeOLEDBWord.
static final intDOCUMENT_2 = 4
Specifies that a given document has been connected to another document format supported by the producing application. Possibly wdMergeSubTypeWorks.
static final intNATIVE = 5
Specifies that a given document has been connected to another document format native to the producing application. Possibly wdMergeSubTypeOLEDBText
static final intEMAIL = 6
Specifies that a given document has been connected to an e-mail application. Possibly wdMergeSubTypeOutlook.
static final intNONE = 7
The type of the external data source is not specified. Possibly wdMergeSubTypeWord.
static final intLEGACY = 8
Specifies that a given document has been connected to a legacy document format supported by the producing application Possibly wdMergeSubTypeWord2000.
static final intMASTER = 9
Specifies that a given document has been connected to a data source which aggregates other data sources.
static final intDEFAULT = 7
Equals to NONE.
 

    • Field Detail

      • TEXT = 0

        public static final int TEXT
        Specifies that a given document has been connected to a text file. Possibly wdMergeSubTypeOther.
      • DATABASE = 1

        public static final int DATABASE
        Specifies that a given document has been connected to a database. Possibly wdMergeSubTypeAccess.
      • ADDRESS_BOOK = 2

        public static final int ADDRESS_BOOK
        Specifies that a given document has been connected to an address book of contacts. Possibly wdMergeSubTypeOAL.
      • DOCUMENT_1 = 3

        public static final int DOCUMENT_1
        Specifies that a given document has been connected to another document format supported by the producing application. Possibly wdMergeSubTypeOLEDBWord.
      • DOCUMENT_2 = 4

        public static final int DOCUMENT_2
        Specifies that a given document has been connected to another document format supported by the producing application. Possibly wdMergeSubTypeWorks.
      • NATIVE = 5

        public static final int NATIVE
        Specifies that a given document has been connected to another document format native to the producing application. Possibly wdMergeSubTypeOLEDBText
      • EMAIL = 6

        public static final int EMAIL
        Specifies that a given document has been connected to an e-mail application. Possibly wdMergeSubTypeOutlook.
      • NONE = 7

        public static final int NONE
        The type of the external data source is not specified. Possibly wdMergeSubTypeWord.
      • LEGACY = 8

        public static final int LEGACY
        Specifies that a given document has been connected to a legacy document format supported by the producing application Possibly wdMergeSubTypeWord2000.
      • MASTER = 9

        public static final int MASTER
        Specifies that a given document has been connected to a data source which aggregates other data sources.
      • DEFAULT = 7

        public static final int DEFAULT
        Equals to NONE.