|
java.lang.Object
Node
CompositeNode
com.aspose.words.Document
- All Implemented Interfaces:
- java.lang.Iterable, java.lang.Iterable, java.lang.Cloneable
public class Document - extends CompositeNode
Represents a Word document.
The Document is a central object in the Aspose.Words library. Loading documents in the following formats is supported: - DOC - Microsoft Word 97 - 2003 Document
- HTML - HTML or XHTML with inline CSS styles
Saving documents in the following formats is supported: - DOC - Microsoft Word 97 - 2003 Document
- HTML - HTML or XHTML Transitional 1.0 with inline CSS styles
- TXT - Plain Text
To open an existing document, pass a file name or a stream into one of the
Document constructors. To create a blank document, call the constructor without parameters. Use one of the Save method overloads to save the document.
MailMerge is the Aspose.Words's reporting engine that allows to populate
reports designed in Microsoft Word with data from various data sources quickly and easily.
The data can be from a java.sql.ResultSet or an array of values.
MailMerge will go through the records found in the data source and insert them into
mail merge fields in the document growing it as necessary. Document stores document-wide information such as Styles,
BuiltInDocumentProperties, CustomDocumentProperties, lists and macros.
Most of these objects are accessible via the corresponding properties of the Document. The Document is a root node of a tree that contains all other nodes of the document.
The tree is a Composite design pattern and in many ways similar to XmlDocument.
The content of the document can be manipulated freely programmatically: Consider using DocumentBuilder that simplifies the task of programmatically creating
or populating the document tree. The Document can contain only Section objects. In Microsoft Word, a valid document needs to have at least one section. Example: Performs a simple insertion of data into merge fields in an existing document.
// Open an existing document.
Document doc = new Document(getMyDir() + "MailMerge.ExecuteArray.doc");
// Fill the fields in the document with user data.
doc.getMailMerge().execute(
new String[] {"FullName", "Company", "Address", "Address2", "City"},
new Object[] {"James Bond", "MI5 Headquarters", "Milbank", "", "London"});
// Send the document in Word format.
doc.save("PersonalizedLetter.doc", SaveFormat.DOC);
|
Constructor Summary |
Document()
Creates a blank Word document.
|
Document(java.lang.String fileName)
Opens an existing document from a file. Automatically detects the file format.
|
Document(java.lang.String fileName, int loadFormat, java.lang.String password)
Opens an existing document from a file.
|
Document(java.io.InputStream stream)
Opens an existing document from a stream. Automatically detects the file format.
|
Document(java.io.InputStream stream, java.lang.String baseUri)
Opens an existing document from a stream. Automatically detects the file format.
|
Document(java.io.InputStream stream, java.lang.String baseUri, int loadFormat, java.lang.String password)
Opens an existing document from a stream.
|
|