java.lang.Objectcom.aspose.words.DocumentBuilder
public class DocumentBuilder
DocumentBuilder makes the process of building a Document easier.
Document is a composite object consisting of a tree of nodes and while inserting content
nodes directly into the tree is possible, it requires good understanding of the tree structure.
DocumentBuilder is a "facade" for the complex structure of Document and allows
to insert content and formatting quickly and easily. Create a DocumentBuilder and associate it with a The DocumentBuilder has an internal cursor where the text will be inserted
when you call Use the Use the Use the Use the Note that Font, ParagraphFormat and PageSetup properties are updated whenever
you navigate to a different place in the document to reflect formatting properties available at the new location.
Constructor Summary |
---|
DocumentBuilder()
Initializes a new instance of this class. |
DocumentBuilder(Document doc)
Initializes a new instance of this class. |
Property Getters/Setters Summary | ||
---|---|---|
boolean | getBold() | |
void | setBold(boolean value) | |
True if the font is formatted as bold. | ||
CellFormat | getCellFormat() | |
Returns an object that represents current table cell formatting properties. | ||
Node | getCurrentNode() | |
Gets the node that is currently selected in this DocumentBuilder. | ||
Paragraph | getCurrentParagraph() | |
Gets the paragraph that is currently selected in this DocumentBuilder. | ||
Section | getCurrentSection() | |
Gets the section that is currently selected in this DocumentBuilder. | ||
Story | getCurrentStory() | |
Gets the story that is currently selected in this DocumentBuilder. | ||
Document | getDocument() | |
void | setDocument(Document value) | |
Gets or sets the |
||
Font | getFont() | |
Returns an object that represents current font formatting properties. | ||
boolean | isAtEndOfParagraph() | |
Returns true if the cursor is at the end of the current paragraph. | ||
boolean | isAtStartOfParagraph() | |
Returns true if the cursor is at the beginning of the current paragraph (no text before the cursor). | ||
boolean | getItalic() | |
void | setItalic(boolean value) | |
True if the font is formatted as italic. | ||
ListFormat | getListFormat() | |
Returns an object that represents current list formatting properties. | ||
PageSetup | getPageSetup() | |
Returns an object that represents current page setup and section properties. | ||
ParagraphFormat | getParagraphFormat() | |
Returns an object that represents current paragraph formatting properties. | ||
RowFormat | getRowFormat() | |
Returns an object that represents current table row formatting properties. | ||
int | getUnderline() | |
void | setUnderline(int value) | |
Gets/sets underline type for the current font. The value of the property is Underline integer constant. |
Method Summary | ||
---|---|---|
void | clearCellAttrs() | |
Reserved for internal use. | ||
void | clearRowAttrs() | |
Reserved for internal use. | ||
void | clearRunAttrs() | |
Reserved for internal use. | ||
Row | deleteRow(int tableIndex, int rowIndex) | |
Deletes a row from a table. | ||
BookmarkEnd | endBookmark(java.lang.String bookmarkName) | |
Marks the current position in the document as a bookmark end. | ||
Row | endRow() | |
Ends a table row in the document. | ||
Table | endTable() | |
Ends a table in the document. | ||
java.lang.Object | fetchInheritedCellAttr(int key) | |
Reserved for internal use. | ||
java.lang.Object | fetchInheritedRowAttr(int key) | |
Reserved for internal use. | ||
java.lang.Object | fetchInheritedRunAttr(int fontAttr) | |
Reserved for internal use. | ||
java.lang.Object | getDirectCellAttr(int key) | |
Reserved for internal use. | ||
java.lang.Object | getDirectRowAttr(int key) | |
Reserved for internal use. | ||
java.lang.Object | getDirectRunAttr(int fontAttr) | |
Reserved for internal use. | ||
void | getDirectRunAttrByIndex(int index, int[] key, java.lang.Object[] value) | |
Reserved for internal use. | ||
int | getDirectRunAttrsCount() | |
Reserved for internal use. | ||
void | insertBreak(int breakType) | |
Inserts a break of the specified type into the document. | ||
Cell | insertCell() | |
Inserts a table cell into the document. | ||
FormField | insertCheckBox(java.lang.String name, boolean defaultValue, int size) | |
Inserts a checkbox form field at the current position. | ||
FormField | insertComboBox(java.lang.String name, java.lang.String[] items, int selectedIndex) | |
Inserts a combobox form field at the current position. | ||
FieldStart | insertField(java.lang.String fieldCode, java.lang.String fieldValue) | |
Inserts a Word field into the document. | ||
Footnote | insertFootnote(int footnoteType, java.lang.String footnoteText) | |
Inserts a footnote or endnote into the document. | ||
void | insertHtml(java.lang.String html) | |
Inserts HTML string into the document. | ||
FieldStart | insertHyperlink(java.lang.String displayText, java.lang.String urlOrBookmark, boolean isBookmark) | |
Inserts a hyperlink into the document. | ||
Shape | insertImage(byte[] imageBytes) | |
Inserts an image from a byte array into the document. The image is inserted inline and at 100% scale. | ||
Shape | insertImage(byte[] imageBytes, double width, double height) | |
Inserts an inline image from a byte array into the document and scales it to the specified size. | ||
Shape | insertImage(byte[] imageBytes, int horzPos, double left, int vertPos, double top, double width, double height, int wrapType) | |
Inserts an image from a byte array at the specified position and size. | ||
Shape | insertImage(java.awt.image.BufferedImage image) | |
Inserts an image from a |
||
Shape | insertImage(java.awt.image.BufferedImage image, double width, double height) | |
Inserts an inline image from a |
||
Shape | insertImage(java.awt.image.BufferedImage image, int horzPos, double left, int vertPos, double top, double width, double height, int wrapType) | |
Inserts an image from a |
||
Shape | insertImage(java.io.InputStream stream) | |
Inserts an image from a stream into the document. The image is inserted inline and at 100% scale. | ||
Shape | insertImage(java.io.InputStream stream, double width, double height) | |
Inserts an inline image from a stream into the document and scales it to the specified size. | ||
Shape | insertImage(java.io.InputStream stream, int horzPos, double left, int vertPos, double top, double width, double height, int wrapType) | |
Inserts an image from a stream at the specified position and size. | ||
Shape | insertImage(java.lang.String fileName) | |
Inserts an image from a file or URL into the document. The image is inserted inline and at 100% scale. | ||
Shape | insertImage(java.lang.String fileName, double width, double height) | |
Inserts an inline image from a file or URL into the document and scales it to the specified size. | ||
Shape | insertImage(java.lang.String fileName, int horzPos, double left, int vertPos, double top, double width, double height, int wrapType) | |
Inserts an image from a file or URL at the specified position and size. | ||
void | insertNode(Node node) | |
Inserts a text level node inside the current paragraph before the cursor. | ||
Paragraph | insertParagraph() | |
Inserts a paragraph break into the document. | ||
void | insertTableOfContents(java.lang.String switches) | |
Inserts a TOC (table of contents) field into the document. | ||
FormField | insertTextInput(java.lang.String name, int type, java.lang.String format, java.lang.String fieldValue, int maxLength) | |
Inserts a text form field at the current position. | ||
void | moveTo(Node node) | |
Moves the cursor to an inline node or to the end of a paragraph. | ||
boolean | moveToBookmark(java.lang.String bookmarkName) | |
Moves the cursor to a bookmark. | ||
boolean | moveToBookmark(java.lang.String bookmarkName, boolean isStart, boolean isAfter) | |
Moves the cursor to a bookmark with greater precision. | ||
void | moveToCell(int tableIndex, int rowIndex, int columnIndex, int characterIndex) | |
Moves the cursor to a table cell in the current section. | ||
void | moveToDocumentEnd() | |
Moves the cursor to the end of the document. | ||
void | moveToDocumentStart() | |
Moves the cursor to the beginning of the document. | ||
void | moveToField(Field field, boolean isAfter) | |
Moves the cursor to a field in the document. | ||
void | moveToHeaderFooter(int headerFooterType) | |
Moves the cursor to the beginning of a header or footer in the current section. | ||
boolean | moveToMergeField(java.lang.String fieldName) | |
Moves the cursor to a position just beyond the specified merge field and removes the merge field. | ||
boolean | moveToMergeField(java.lang.String fieldName, boolean isAfter, boolean isDeleteField) | |
Moves the merge field to the specified merge field. | ||
void | moveToParagraph(int paragraphIndex, int characterIndex) | |
Moves the cursor to a paragraph in the current section. | ||
void | moveToSection(int sectionIndex) | |
Moves the cursor to the beginning of the body in a specified section. | ||
void | popFont() | |
Retrieves character formatting previously saved on the stack. | ||
void | pushFont() | |
Saves current character formatting onto the stack. | ||
void | setCellAttr(int key, java.lang.Object value) | |
Reserved for internal use. | ||
void | setRowAttr(int key, java.lang.Object value) | |
Reserved for internal use. | ||
void | setRunAttr(int fontAttr, java.lang.Object value) | |
Reserved for internal use. | ||
BookmarkStart | startBookmark(java.lang.String bookmarkName) | |
Marks the current position in the document as a bookmark start. | ||
Table | startTable() | |
Starts a table in the document. | ||
void | write(java.lang.String text) | |
Inserts a string into the document at the current insert position. | ||
void | writeln() | |
Inserts a paragraph break into the document. | ||
void | writeln(java.lang.String text) | |
Inserts a string and a paragraph break into the document. |
Constructor Detail |
---|
public DocumentBuilder() throws java.lang.Exception
Example:
Inserts formatted text using DocumentBuilder.DocumentBuilder builder = new DocumentBuilder(); // Specify font formatting before adding text. Font font = builder.getFont(); font.setSize(16); font.setBold(true); font.setColor(Color.BLUE); font.setName("Arial"); font.setUnderline(Underline.DASH); builder.write("Sample text.");
public DocumentBuilder(Document doc) throws java.lang.Exception
doc
- The Document object to attach to.Example:
Creates headers and footers in a document using DocumentBuilder.// Create a blank document. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Specify that we want headers and footers different for first, even and odd pages. builder.getPageSetup().setDifferentFirstPageHeaderFooter(true); builder.getPageSetup().setOddAndEvenPagesHeaderFooter(true); // Create the headers. builder.moveToHeaderFooter(HeaderFooterType.HEADER_FIRST); builder.write("Header First"); builder.moveToHeaderFooter(HeaderFooterType.HEADER_EVEN); builder.write("Header Even"); builder.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY); builder.write("Header Odd"); // Create three pages in the document. builder.moveToSection(0); builder.writeln("Page1"); builder.insertBreak(BreakType.PAGE_BREAK); builder.writeln("Page2"); builder.insertBreak(BreakType.PAGE_BREAK); builder.writeln("Page3"); doc.save(getMyDir() + "DocumentBuilder.HeadersAndFooters Out.doc");
Property Getters/Setters Detail |
---|
getDocument/setDocument | |
public Document getDocument() / public void setDocument(Document value) |
Example:
Shows how to insert sections using DocumentBuilder, specify page setup for a section and reset page setup to defaults.DocumentBuilder builder = new DocumentBuilder(); // Modify the first section in the document. builder.getPageSetup().setOrientation(Orientation.LANDSCAPE); builder.getPageSetup().setVerticalAlignment(PageVerticalAlignment.CENTER); builder.writeln("Section 1, landscape oriented and text vertically centered."); // Start a new section and reset its formatting to defaults. builder.insertBreak(BreakType.SECTION_BREAK_NEW_PAGE); builder.getPageSetup().clearFormatting(); builder.writeln("Section 2, back to default Letter paper size, portrait orientation and top alignment."); builder.getDocument().save(getMyDir() + "PageSetup.ClearFormatting Out.doc");
getFont | |
public Font getFont() |
Use Font to access and modify font formatting properties.
Specify font formatting before inserting text.
Example:
Inserts a string surrounded by a border into a document.DocumentBuilder builder = new DocumentBuilder(); builder.getFont().getBorder().setColor(Color.GREEN); builder.getFont().getBorder().setLineWidth(2.5); builder.getFont().getBorder().setLineStyle(LineStyle.DASH_DOT_STROKER); builder.write("run of text in a green border");
getBold/setBold | |
public boolean getBold() / public void setBold(boolean value) |
Example:
Fills document merge fields with some data.Document doc = new Document(getMyDir() + "DocumentBuilder.FillingDocument.doc"); DocumentBuilder builder = new DocumentBuilder(doc); builder.moveToMergeField("TeamLeaderName"); builder.setBold(true); builder.writeln("Roman Korchagin"); builder.moveToMergeField("SoftwareDeveloper1Name"); builder.setItalic(true); builder.writeln("Dmitry Vorobyev"); builder.moveToMergeField("SoftwareDeveloper2Name"); builder.setItalic(true); builder.writeln("Vladimir Averkin"); doc.save(getMyDir() + "DocumentBuilder.FillingDocument Out.doc");
getItalic/setItalic | |
public boolean getItalic() / public void setItalic(boolean value) |
Example:
Fills document merge fields with some data.Document doc = new Document(getMyDir() + "DocumentBuilder.FillingDocument.doc"); DocumentBuilder builder = new DocumentBuilder(doc); builder.moveToMergeField("TeamLeaderName"); builder.setBold(true); builder.writeln("Roman Korchagin"); builder.moveToMergeField("SoftwareDeveloper1Name"); builder.setItalic(true); builder.writeln("Dmitry Vorobyev"); builder.moveToMergeField("SoftwareDeveloper2Name"); builder.setItalic(true); builder.writeln("Vladimir Averkin"); doc.save(getMyDir() + "DocumentBuilder.FillingDocument Out.doc");
getUnderline/setUnderline | |
public int getUnderline() / public void setUnderline(int value) |
getParagraphFormat | |
public ParagraphFormat getParagraphFormat() |
Example:
Inserts a paragraph with a top border.DocumentBuilder builder = new DocumentBuilder(); Border topBorder = builder.getParagraphFormat().getBorders().getByBorderType(BorderType.TOP); topBorder.setColor(Color.RED); topBorder.setLineStyle(LineStyle.DASH_SMALL_GAP); topBorder.setLineWidth(4); builder.writeln("Hello World!");
getListFormat | |
public ListFormat getListFormat() |
Example:
Shows how to apply default bulleted or numbered list formatting to paragraphs when using DocumentBuilder.DocumentBuilder builder = new DocumentBuilder(); builder.writeln("Aspose.Words allows:"); builder.writeln(); // Start a numbered list with default formatting. builder.getListFormat().applyNumberDefault(); builder.writeln("Opening documents from different formats:"); // Go to second list level, add more text. builder.getListFormat().listIndent(); builder.writeln("DOC"); builder.writeln("PDF"); builder.writeln("HTML"); // Outdent to the first list level. builder.getListFormat().listOutdent(); builder.writeln("Processing documents"); builder.writeln("Saving documents in different formats:"); // Indent the list level again. builder.getListFormat().listIndent(); builder.writeln("DOC"); builder.writeln("PDF"); builder.writeln("HTML"); builder.writeln("MHTML"); builder.writeln("Plain text"); // Outdent the list level again. builder.getListFormat().listOutdent(); builder.writeln("Doing many other things!"); // End the numbered list. builder.getListFormat().removeNumbers(); builder.writeln(); builder.writeln("Aspose.Words main advantages are:"); builder.writeln(); // Start a bulleted list with default formatting. builder.getListFormat().applyBulletDefault(); builder.writeln("Great performance"); builder.writeln("High reliability"); builder.writeln("Quality code and working"); builder.writeln("Wide variety of features"); builder.writeln("Easy to understand API"); // End the bulleted list. builder.getListFormat().removeNumbers(); builder.getDocument().save(getMyDir() + "Lists.ApplyDefaultBulletsAndNumbers Out.doc");
getPageSetup | |
public PageSetup getPageSetup() |
Example:
Shows how to insert sections using DocumentBuilder, specify page setup for a section and reset page setup to defaults.DocumentBuilder builder = new DocumentBuilder(); // Modify the first section in the document. builder.getPageSetup().setOrientation(Orientation.LANDSCAPE); builder.getPageSetup().setVerticalAlignment(PageVerticalAlignment.CENTER); builder.writeln("Section 1, landscape oriented and text vertically centered."); // Start a new section and reset its formatting to defaults. builder.insertBreak(BreakType.SECTION_BREAK_NEW_PAGE); builder.getPageSetup().clearFormatting(); builder.writeln("Section 2, back to default Letter paper size, portrait orientation and top alignment."); builder.getDocument().save(getMyDir() + "PageSetup.ClearFormatting Out.doc");
getRowFormat | |
public RowFormat getRowFormat() |
getCellFormat | |
public CellFormat getCellFormat() |
isAtStartOfParagraph | |
public boolean isAtStartOfParagraph() |
isAtEndOfParagraph | |
public boolean isAtEndOfParagraph() |
getCurrentNode | |
public Node getCurrentNode() |
CurrentNode is a cursor of DocumentBuilder and points to a Node that is a direct child of a Paragraph. Any insert operations you perform using DocumentBuilder will insert before the CurrentNode.
When the current paragraph is empty or the cursor is positioned just before the end of the paragraph, CurrentNode returns null.
Example:
Shows how to move between nodes and manipulate current ones.Document doc = new Document(getMyDir() + "DocumentBuilder.WorkingWithNodes.doc"); DocumentBuilder builder = new DocumentBuilder(doc); // Move to a bookmark and delete the parent paragraph. builder.moveToBookmark("ParaToDelete"); builder.getCurrentParagraph().remove(); // Move to a particular paragraph's run and replace all occurences of "bad" with "good" within this run. builder.moveTo(doc.getLastSection().getBody().getParagraphs().get(0).getRuns().get(0)); builder.getCurrentNode().getRange().replace("bad", "good", false, true); // Mark the beginning of the document. builder.moveToDocumentStart(); builder.writeln("Start of document."); // Mark the ending of the document. builder.moveToDocumentEnd(); builder.writeln("End of document."); doc.save(getMyDir() + "DocumentBuilder.WorkingWithNodes Out.doc");
getCurrentParagraph | |
public Paragraph getCurrentParagraph() |
Example:
Shows how to move between nodes and manipulate current ones.Document doc = new Document(getMyDir() + "DocumentBuilder.WorkingWithNodes.doc"); DocumentBuilder builder = new DocumentBuilder(doc); // Move to a bookmark and delete the parent paragraph. builder.moveToBookmark("ParaToDelete"); builder.getCurrentParagraph().remove(); // Move to a particular paragraph's run and replace all occurences of "bad" with "good" within this run. builder.moveTo(doc.getLastSection().getBody().getParagraphs().get(0).getRuns().get(0)); builder.getCurrentNode().getRange().replace("bad", "good", false, true); // Mark the beginning of the document. builder.moveToDocumentStart(); builder.writeln("Start of document."); // Mark the ending of the document. builder.moveToDocumentEnd(); builder.writeln("End of document."); doc.save(getMyDir() + "DocumentBuilder.WorkingWithNodes Out.doc");
getCurrentStory | |
public Story getCurrentStory() |
getCurrentSection | |
public Section getCurrentSection() |
Example:
Shows how to insert a floating image and specify its position and size.// This creates a builder and also an empty document inside the builder. DocumentBuilder builder = new DocumentBuilder(); // By default, the image is inline. Shape shape = builder.insertImage(getMyDir() + "Hammer.wmf"); // Make the image float, put it behind text and center on the page. shape.setWrapType(WrapType.NONE); // Make position relative to the page. shape.setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE); shape.setRelativeVerticalPosition(RelativeVerticalPosition.PAGE); // Make the shape occupy a band 50 points high at the very top of the page. shape.setLeft(0); shape.setTop(0); shape.setWidth(builder.getCurrentSection().getPageSetup().getPageWidth()); shape.setHeight(50); builder.getDocument().save(getMyDir() + "Image.CreateFloatingPositionSize Out.doc");
Method Detail |
---|
moveToDocumentStart | |
public void moveToDocumentStart() throws java.lang.Exception |
Example:
Shows how to move between nodes and manipulate current ones.Document doc = new Document(getMyDir() + "DocumentBuilder.WorkingWithNodes.doc"); DocumentBuilder builder = new DocumentBuilder(doc); // Move to a bookmark and delete the parent paragraph. builder.moveToBookmark("ParaToDelete"); builder.getCurrentParagraph().remove(); // Move to a particular paragraph's run and replace all occurences of "bad" with "good" within this run. builder.moveTo(doc.getLastSection().getBody().getParagraphs().get(0).getRuns().get(0)); builder.getCurrentNode().getRange().replace("bad", "good", false, true); // Mark the beginning of the document. builder.moveToDocumentStart(); builder.writeln("Start of document."); // Mark the ending of the document. builder.moveToDocumentEnd(); builder.writeln("End of document."); doc.save(getMyDir() + "DocumentBuilder.WorkingWithNodes Out.doc");
moveToDocumentEnd | |
public void moveToDocumentEnd() throws java.lang.Exception |
Example:
Shows how to move between nodes and manipulate current ones.Document doc = new Document(getMyDir() + "DocumentBuilder.WorkingWithNodes.doc"); DocumentBuilder builder = new DocumentBuilder(doc); // Move to a bookmark and delete the parent paragraph. builder.moveToBookmark("ParaToDelete"); builder.getCurrentParagraph().remove(); // Move to a particular paragraph's run and replace all occurences of "bad" with "good" within this run. builder.moveTo(doc.getLastSection().getBody().getParagraphs().get(0).getRuns().get(0)); builder.getCurrentNode().getRange().replace("bad", "good", false, true); // Mark the beginning of the document. builder.moveToDocumentStart(); builder.writeln("Start of document."); // Mark the ending of the document. builder.moveToDocumentEnd(); builder.writeln("End of document."); doc.save(getMyDir() + "DocumentBuilder.WorkingWithNodes Out.doc");
moveToSection | |
public void moveToSection(int sectionIndex) throws java.lang.Exception |
When sectionIndex is greater than or equal to 0, it specifies an index from the beginning of the document with 0 being the first section. When sectionIndex is less than 0, it specified an index from the end of the document with -1 being the last section.
The cursor is moved to the first paragraph in the Body of the specified section.
sectionIndex
- The index of the section to move to.Example:
Creates headers and footers in a document using DocumentBuilder.// Create a blank document. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Specify that we want headers and footers different for first, even and odd pages. builder.getPageSetup().setDifferentFirstPageHeaderFooter(true); builder.getPageSetup().setOddAndEvenPagesHeaderFooter(true); // Create the headers. builder.moveToHeaderFooter(HeaderFooterType.HEADER_FIRST); builder.write("Header First"); builder.moveToHeaderFooter(HeaderFooterType.HEADER_EVEN); builder.write("Header Even"); builder.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY); builder.write("Header Odd"); // Create three pages in the document. builder.moveToSection(0); builder.writeln("Page1"); builder.insertBreak(BreakType.PAGE_BREAK); builder.writeln("Page2"); builder.insertBreak(BreakType.PAGE_BREAK); builder.writeln("Page3"); doc.save(getMyDir() + "DocumentBuilder.HeadersAndFooters Out.doc");
moveToHeaderFooter | |
public void moveToHeaderFooter(int headerFooterType) throws java.lang.Exception |
After you moved the cursor into a header or footer, you can use the rest of DocumentBuilder methods to modify the contents of the header or footer.
If you want to create headers and footers different for the first page, you need
to set
If you want to create headers and footers different for even and odd pages, you need
to set
Use
headerFooterType
- A Example:
Inserts a watermark image into a document using DocumentBuilder.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // The best place for the watermark image is in the header or footer so it is shown on every page. builder.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY); // Insert a floating picture. BufferedImage image = javax.imageio.ImageIO.read(new File(getMyDir() + "Watermark.png")); Shape shape = builder.insertImage(image); shape.setWrapType(WrapType.NONE); shape.setBehindText(true); shape.setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE); shape.setRelativeVerticalPosition(RelativeVerticalPosition.PAGE); // Calculate image left and top position so it appears in the centre of the page. shape.setLeft((builder.getPageSetup().getPageWidth() - shape.getWidth()) / 2); shape.setTop((builder.getPageSetup().getPageHeight() - shape.getHeight()) / 2); doc.save(getMyDir() + "DocumentBuilder.InsertWatermark Out.doc");
Example:
Creates headers and footers in a document using DocumentBuilder.// Create a blank document. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Specify that we want headers and footers different for first, even and odd pages. builder.getPageSetup().setDifferentFirstPageHeaderFooter(true); builder.getPageSetup().setOddAndEvenPagesHeaderFooter(true); // Create the headers. builder.moveToHeaderFooter(HeaderFooterType.HEADER_FIRST); builder.write("Header First"); builder.moveToHeaderFooter(HeaderFooterType.HEADER_EVEN); builder.write("Header Even"); builder.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY); builder.write("Header Odd"); // Create three pages in the document. builder.moveToSection(0); builder.writeln("Page1"); builder.insertBreak(BreakType.PAGE_BREAK); builder.writeln("Page2"); builder.insertBreak(BreakType.PAGE_BREAK); builder.writeln("Page3"); doc.save(getMyDir() + "DocumentBuilder.HeadersAndFooters Out.doc");
moveToMergeField | |
public boolean moveToMergeField(java.lang.String fieldName) throws java.lang.Exception |
Note that this method deletes the merge field from the document after moving the cursor.
fieldName
- The case-insensitive name of the mail merge field.Example:
Shows how to insert checkbox form fields into a document during mail merge.// File 'MailMerge.InsertCheckBox.doc' is a template // containing the table with the following fields in it: // <<TableStart:StudentCourse>> <<CourseName>> <<TableEnd:StudentCourse>>. public void mailMergeInsertCheckBox() throws Exception { Document doc = new Document(getMyDir() + "MailMerge.InsertCheckBox.doc"); // Add a hadler for the MergeField event. doc.getMailMerge().addMergeFieldEventHandler(new HandleMergeFieldInsertCheckBox()); // Execute mail merge with regions. mCheckBoxCount = 0; StudentCourseDataTable dataTable = getStudentCourseDataTable(); doc.getMailMerge().executeWithRegions(dataTable); // Save resulting document with a new name. doc.save(getMyDir() + "MailMerge.InsertCheckBox Out.doc"); } /// <summary> /// Counter for CheckBox name generation /// </summary> private int mCheckBoxCount; /// <summary> /// This is called for each merge field in the document /// when Document.MailMerge.ExecuteWithRegions is called. /// </summary> private class HandleMergeFieldInsertCheckBox implements MergeFieldEventHandler { public void mergeField(Object sender, MergeFieldEventArgs e) throws Exception { if ("CourseName".equals(e.getDocumentFieldName())) { // Insert the checkbox for this merge field, using DocumentBuilder. DocumentBuilder builder = new DocumentBuilder(e.getDocument()); builder.moveToMergeField(e.getFieldName()); builder.insertCheckBox(e.getDocumentFieldName() + mCheckBoxCount, false, 0); builder.write((String)e.getFieldValue()); mCheckBoxCount++; } } } /// <summary> /// Create DataTable and fill it with data. /// In real life this DataTable should be filled from a database. /// </summary> private StudentCourseDataTable getStudentCourseDataTable() { ArrayList data = new ArrayList(); for (int i = 0; i < 10; i++) data.add("Course " + i); return new StudentCourseDataTable(data); } /// <summary> /// This is a simple implementation of a custom mail merge data source over an ArrayList. /// </summary> public class StudentCourseDataTable implements IMailMergeDataSource { private ArrayList mData; private int mRecordIndex; public StudentCourseDataTable(ArrayList data) { mData = data; // When the data source is initialized, it must be positioned before the first record. mRecordIndex= -1; } /// <summary> /// The name of the data source. Used by Aspose.Words only when executing mail merge with repeatable regions. /// </summary> public String getTableName() { return "StudentCourse"; } /// <summary> /// Aspose.Words calls this to get a value for every data field. /// </summary> public boolean getValue(String fieldName, Object[] fieldValue) { if ("CourseName".equals(fieldName)) { fieldValue[0] = mData.get(mRecordIndex); return true; } else { // A field with this name was not found, return false to the Aspose.Words mail merge engine. fieldValue[0] = null; return false; } } /// <summary> /// A standard implementation for moving to a next record in a collection. /// </summary> public boolean moveNext() { if (!isEof()) mRecordIndex++; return (!isEof()); } private boolean isEof() { return (mRecordIndex >= mData.size()); } }
Example:
Fills document merge fields with some data.Document doc = new Document(getMyDir() + "DocumentBuilder.FillingDocument.doc"); DocumentBuilder builder = new DocumentBuilder(doc); builder.moveToMergeField("TeamLeaderName"); builder.setBold(true); builder.writeln("Roman Korchagin"); builder.moveToMergeField("SoftwareDeveloper1Name"); builder.setItalic(true); builder.writeln("Dmitry Vorobyev"); builder.moveToMergeField("SoftwareDeveloper2Name"); builder.setItalic(true); builder.writeln("Vladimir Averkin"); doc.save(getMyDir() + "DocumentBuilder.FillingDocument Out.doc");
moveToMergeField | |
public boolean moveToMergeField(java.lang.String fieldName, boolean isAfter, boolean isDeleteField) throws java.lang.Exception |
fieldName
- The case-insensitive name of the mail merge field.isAfter
- When true, moves the cursor to be after the field end.
When false, moves the cursor to be before the field start. isDeleteField
- When true, deletes the merge field.moveToField | |
public void moveToField(Field field, boolean isAfter) throws java.lang.Exception |
field
- The field to move the cursor to.isAfter
- When true, moves the cursor to be after the field end.
When false, moves the cursor to be before the field start. moveToBookmark | |
public boolean moveToBookmark(java.lang.String bookmarkName) throws java.lang.Exception |
Moves the cursor to a position just after the start of the bookmark with the specified name.
The comparison is not case-sensitive. If the bookmark was not found, false is returned and the cursor is not moved.
Inserting new text does not replace existing text of the bookmark.
Note that some bookmarks in the document are assigned to form fields. Moving to such a bookmark and inserting text there inserts the text into the form field code. Although this will not invalidate the form field, the inserted text will not be visible because it becomes part of the field code.
bookmarkName
- The name of the bookmark to move the cursor to.Example:
Shows how to move between nodes and manipulate current ones.Document doc = new Document(getMyDir() + "DocumentBuilder.WorkingWithNodes.doc"); DocumentBuilder builder = new DocumentBuilder(doc); // Move to a bookmark and delete the parent paragraph. builder.moveToBookmark("ParaToDelete"); builder.getCurrentParagraph().remove(); // Move to a particular paragraph's run and replace all occurences of "bad" with "good" within this run. builder.moveTo(doc.getLastSection().getBody().getParagraphs().get(0).getRuns().get(0)); builder.getCurrentNode().getRange().replace("bad", "good", false, true); // Mark the beginning of the document. builder.moveToDocumentStart(); builder.writeln("Start of document."); // Mark the ending of the document. builder.moveToDocumentEnd(); builder.writeln("End of document."); doc.save(getMyDir() + "DocumentBuilder.WorkingWithNodes Out.doc");
moveToBookmark | |
public boolean moveToBookmark(java.lang.String bookmarkName, boolean isStart, boolean isAfter) throws java.lang.Exception |
Moves the cursor to a position before or after the bookmark start or end.
The comparison is not case-sensitive. If the bookmark was not found, false is returned and the cursor is not moved.
bookmarkName
- The name of the bookmark to move the cursor to.isStart
- When true, moves the cursor to the beginning of the bookmark.
When false, moves the cursor to the end of the bookmark.isAfter
- When true, moves the cursor to be after the bookmark
start or end position. When false, moves the cursor to be before the bookmark
start or end position.moveToParagraph | |
public void moveToParagraph(int paragraphIndex, int characterIndex) throws java.lang.Exception |
The navigation is performed inside the current story of the current section. That is, if you moved the cursor to the primary header of the first section, then paragraphIndex specified the index of the paragraph inside that header of that section.
When paragraphIndex is greater than or equal to 0, it specifies an index from the beginning of the section with 0 being the first paragraph. When paragraphIndex is less than 0, it specified an index from the end of the section with -1 being the last paragraph.
paragraphIndex
- The index of the paragraph to move to.characterIndex
- The index of the character inside the paragraph.
Currently can only specify 0 to move to the beginning of the paragraph or -1 to
move to the end of the paragraph.
moveToCell | |
public void moveToCell(int tableIndex, int rowIndex, int columnIndex, int characterIndex) throws java.lang.Exception |
The navigation is performed inside the current story of the current section.
For the index parameters, when index is greater than or equal to 0, it specifies an index from the beginning with 0 being the first element. When index is less than 0, it specified an index from the end with -1 being the last element.
tableIndex
- The index of the table to move to.rowIndex
- The index of the row in the table.columnIndex
- The index of the column in the table.characterIndex
- The index of the character inside the cell.
Currently can only specify 0 to move to the beginning of the cell or -1 to
move to the end of the cell.moveTo | |
public void moveTo(Node node) throws java.lang.Exception |
When node is an inline-level node, the cursor is moved to this node and further content will be inserted before that node.
When node is a Paragraph, the cursor is moved to the end of the paragraph and further content will be inserted just before the paragraph break.
node
- The node must be a paragraph or a direct child of a paragraph.Example:
Shows how to move between nodes and manipulate current ones.Document doc = new Document(getMyDir() + "DocumentBuilder.WorkingWithNodes.doc"); DocumentBuilder builder = new DocumentBuilder(doc); // Move to a bookmark and delete the parent paragraph. builder.moveToBookmark("ParaToDelete"); builder.getCurrentParagraph().remove(); // Move to a particular paragraph's run and replace all occurences of "bad" with "good" within this run. builder.moveTo(doc.getLastSection().getBody().getParagraphs().get(0).getRuns().get(0)); builder.getCurrentNode().getRange().replace("bad", "good", false, true); // Mark the beginning of the document. builder.moveToDocumentStart(); builder.writeln("Start of document."); // Mark the ending of the document. builder.moveToDocumentEnd(); builder.writeln("End of document."); doc.save(getMyDir() + "DocumentBuilder.WorkingWithNodes Out.doc");
deleteRow | |
public Row deleteRow(int tableIndex, int rowIndex) throws java.lang.Exception |
If the cursor is inside the row that is being deleted, the cursor is moved out to the next row or to the next paragraph after the table.
If you delete a row from a table that contains only one row, the whole table is deleted.
For the index parameters, when index is greater than or equal to 0, it specifies an index from the beginning with 0 being the first element. When index is less than 0, it specified an index from the end with -1 being the last element.
tableIndex
- The index of the table.rowIndex
- The index of the row in the table.write | |
public void write(java.lang.String text) throws java.lang.Exception |
text
- The string to insert into the document.Example:
Inserts a string surrounded by a border into a document.DocumentBuilder builder = new DocumentBuilder(); builder.getFont().getBorder().setColor(Color.GREEN); builder.getFont().getBorder().setLineWidth(2.5); builder.getFont().getBorder().setLineStyle(LineStyle.DASH_DOT_STROKER); builder.write("run of text in a green border");
writeln | |
public void writeln(java.lang.String text) throws java.lang.Exception |
text
- The string to insert into the document.writeln | |
public void writeln() throws java.lang.Exception |
Calls
Example:
Inserts a paragraph with a top border.DocumentBuilder builder = new DocumentBuilder(); Border topBorder = builder.getParagraphFormat().getBorders().getByBorderType(BorderType.TOP); topBorder.setColor(Color.RED); topBorder.setLineStyle(LineStyle.DASH_SMALL_GAP); topBorder.setLineWidth(4); builder.writeln("Hello World!");
insertParagraph | |
public Paragraph insertParagraph() throws java.lang.Exception |
Current paragraph formatting specified by the
Breaks the current paragraph in two. After inserting the paragraph, the cursor is placed at the beginning of the new paragraph.
insertBreak | |
public void insertBreak(int breakType) throws java.lang.Exception |
breakType
- A Example:
Creates headers and footers in a document using DocumentBuilder.// Create a blank document. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Specify that we want headers and footers different for first, even and odd pages. builder.getPageSetup().setDifferentFirstPageHeaderFooter(true); builder.getPageSetup().setOddAndEvenPagesHeaderFooter(true); // Create the headers. builder.moveToHeaderFooter(HeaderFooterType.HEADER_FIRST); builder.write("Header First"); builder.moveToHeaderFooter(HeaderFooterType.HEADER_EVEN); builder.write("Header Even"); builder.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY); builder.write("Header Odd"); // Create three pages in the document. builder.moveToSection(0); builder.writeln("Page1"); builder.insertBreak(BreakType.PAGE_BREAK); builder.writeln("Page2"); builder.insertBreak(BreakType.PAGE_BREAK); builder.writeln("Page3"); doc.save(getMyDir() + "DocumentBuilder.HeadersAndFooters Out.doc");
Example:
Shows how to insert sections using DocumentBuilder, specify page setup for a section and reset page setup to defaults.DocumentBuilder builder = new DocumentBuilder(); // Modify the first section in the document. builder.getPageSetup().setOrientation(Orientation.LANDSCAPE); builder.getPageSetup().setVerticalAlignment(PageVerticalAlignment.CENTER); builder.writeln("Section 1, landscape oriented and text vertically centered."); // Start a new section and reset its formatting to defaults. builder.insertBreak(BreakType.SECTION_BREAK_NEW_PAGE); builder.getPageSetup().clearFormatting(); builder.writeln("Section 2, back to default Letter paper size, portrait orientation and top alignment."); builder.getDocument().save(getMyDir() + "PageSetup.ClearFormatting Out.doc");
insertTableOfContents | |
public void insertTableOfContents(java.lang.String switches) throws java.lang.Exception |
This method inserts a TOC (table of contents) field into the document at the current position.
A table of contents in a Word document can be built in a number of ways and formatted using a variety of options. The way the table is built and displayed by Microsoft Word is controlled by the field switches.
The easiest way to specify the switches is to insert and configure a table of contents into a Word document using the Insert->Reference->Index and Tables menu, then switch display of field codes on to see the switches. You can press Alt+F9 in Microsoft Word to toggle display of field codes on or off.
For example, after creating a table of contents, the following field is inserted into the document: { TOC \o "1-3" \h \z \u }. You can copy \o "1-3" \h \z \u and use it as the switches parameter.
Note that InsertTableOfContents will only insert a TOC field, but will not actually build the table of contents. The table of contents is built by Microsoft Word when the field is updated.
If you insert a table of contents using this method and then open the file in Microsoft Word, you will not see the table of contents because the TOC field has not yet been updated.
In Microsoft Word, fields are not automatically updated when a document is opened, but you can update fields in a document at any time by pressing F9.
switches
- The TOC field switches.Example:
Demonstrates how to insert a TOC into a document using heading styles as entries.DocumentBuilder builder = new DocumentBuilder(); // Insrt a table of contents at the beginning of the document. builder.insertTableOfContents("\\o \"1-3\" \\h \\z \\u"); // Build a document with complex structure by applying different heading styles thus creating TOC entries. builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_1); builder.writeln("Heading 1"); builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_2); builder.writeln("Heading 1.1"); builder.writeln("Heading 1.2"); builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_1); builder.writeln("Heading 2"); builder.writeln("Heading 3"); builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_2); builder.writeln("Heading 3.1"); builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_3); builder.writeln("Heading 3.1.1"); builder.writeln("Heading 3.1.2"); builder.writeln("Heading 3.1.3"); builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_2); builder.writeln("Heading 3.2"); builder.writeln("Heading 3.3"); builder.getDocument().save(getMyDir() + "DocumentBuilder.InsertToc Out.doc"); // Don't forget to update fields of the document by pressing F9 in Microsoft Word to see the TOC.
insertField | |
public FieldStart insertField(java.lang.String fieldCode, java.lang.String fieldValue) throws java.lang.Exception |
Fields in MS Word documents consist of a field code and a field result. The field code is like a formula and the field result is like the value that the formula produces. The field code may also contain field switches that are like additional instructions to perform a specific action.
You can switch between displaying field codes and results in your document in MS Word using the keyboard shortcut Alt+F9. Field codes appear between curly braces ( { } ).
To create fields using
fieldCode
- Field code to insert (without curly braces).fieldValue
- Field value to insert. Pass null for fields that do not have a value.Example:
Shows how to control page numbering per section.// This document has two sections, but no page numbers yet. Document doc = new Document(getMyDir() + "PageSetup.PageNumbering.doc"); // Use document builder to create a header with a page number field for the first section. // The page number will look like "Page V". DocumentBuilder builder = new DocumentBuilder(doc); builder.moveToSection(0); builder.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY); builder.write("Page "); builder.insertField("PAGE", ""); // Set first section page numbering. Section section = doc.getSections().get(0); section.getPageSetup().setRestartPageNumbering(true); section.getPageSetup().setPageStartingNumber(5); section.getPageSetup().setPageNumberStyle(NumberStyle.UPPERCASE_ROMAN); // Create a header for the section section. // The page number will look like " - 10 - ". builder.moveToSection(1); builder.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY); builder.getParagraphFormat().setAlignment(ParagraphAlignment.CENTER); builder.write(" - "); builder.insertField("PAGE", ""); builder.write(" - "); // Set second section page numbering. section = doc.getSections().get(1); section.getPageSetup().setPageStartingNumber(10); section.getPageSetup().setRestartPageNumbering(true); section.getPageSetup().setPageNumberStyle(NumberStyle.ARABIC); doc.save(getMyDir() + "PageSetup.PageNumbering Out.doc");
Example:
Inserts a merge field into a document using DocumentBuilder.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.insertField("MERGEFIELD MyFieldName \\* MERGEFORMAT", "");
insertHyperlink | |
public FieldStart insertHyperlink(java.lang.String displayText, java.lang.String urlOrBookmark, boolean isBookmark) throws java.lang.Exception |
Note that you need to specify font formatting for the hyperlink display text explicitly
using the
This methods internally calls
displayText
- Text of the link to be displayed in the document.urlOrBookmark
- Link destination. Can be a url or a name of a bookmark inside the document.
This method always adds apostrophes at the beginning and end of the url.isBookmark
- True if the previous parameter is a name of a bookmark inside the document;
false is the previous parameter is a URL.Example:
Shows how to use temporarily save and restore character formatting when building a document with DocumentBuilder.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Set up font formatting and write text that goes before the hyperlink. builder.getFont().setName("Arial"); builder.getFont().setSize(24); builder.getFont().setBold(true); builder.write("To go to an important location, click "); // Save the font formatting so we use different formatting for hyperlink and restore old formatting later. builder.pushFont(); // Set new font formatting for the hyperlink and insert the hyperlink. // The "Hyperlink" style is a Microsoft Word built-in style so we don't have to worry to // create it, it will be created automatically if it does not yet exist in the document. builder.getFont().setStyleIdentifier(StyleIdentifier.HYPERLINK); builder.insertHyperlink("here", "http://www.google.com", false); // Restore the formatting that was before the hyperlink. builder.popFont(); builder.writeln(". We hope you enjoyed the example."); doc.save(getMyDir() + "DocumentBuilder.PushPopFont Out.doc");
Example:
Inserts a hyperlink referencing local bookmark.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.startBookmark("Bookmark1"); builder.write("Bookmarked text."); builder.endBookmark("Bookmark1"); builder.writeln("Some other text"); // Specify font formatting for the hyperlink. builder.getFont().setColor(Color.BLUE); builder.getFont().setUnderline(Underline.SINGLE); // Insert hyperlink. // Switch \o is used to provide hyperlink tip text. builder.insertHyperlink("Hyperlink Text", "Bookmark1\" \\o \"Hyperlink Tip", true); // Clear hyperlink formatting. builder.getFont().clearFormatting(); doc.save(getMyDir() + "DocumentBuilder.InsertHyperlinkToLocalBookmark Out.doc");
Example:
Inserts a hyperlink into a document using DocumentBuilder.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.write("Please make sure to visit "); // Specify font formatting for the hyperlink. builder.getFont().setColor(Color.BLUE); builder.getFont().setUnderline(Underline.SINGLE); // Insert the link. builder.insertHyperlink("Aspose Website", "http://www.aspose.com", false); // Revert to default formatting. builder.getFont().clearFormatting(); builder.write(" for more information."); doc.save(getMyDir() + "DocumentBuilder.InsertHyperlink Out.doc");
insertTextInput | |
public FormField insertTextInput(java.lang.String name, int type, java.lang.String format, java.lang.String fieldValue, int maxLength) throws java.lang.Exception |
If you specify a name for the form field, then a bookmark is automatically created with the same name.
name
- The name of the form field. Can be an empty string.type
- A format
- Format string used to format the value of the form field.fieldValue
- Text that will be shown in the field.maxLength
- Maximum length the user can enter into the form field. Set to zero for unlimited length.Example:
Builds a sample form to fill.DocumentBuilder builder = new DocumentBuilder(); // Insert a text form field for input a name. builder.insertTextInput("", TextFormFieldType.REGULAR_TEXT, "", "Enter your name here", 30); // Insert 2 blank lines. builder.writeln(""); builder.writeln(""); String[] items = new String[] { "-- Select your favorite footwear --", "Sneakers", "Oxfords", "Flip-flops", "Other", "I prefer to be barefoot" }; // Insert a combo box to select a footwear type. builder.insertComboBox("", items, 0); // Insert 2 blank lines. builder.writeln(""); builder.writeln(""); // Insert a check box to ensure the form filler does look after his/her footwear. builder.insertCheckBox("", true, 0); builder.writeln("My boots are always polished and nice-looking."); builder.getDocument().save(getMyDir() + "DocumentBuilder.CreateForm Out.doc");
insertCheckBox | |
public FormField insertCheckBox(java.lang.String name, boolean defaultValue, int size) throws java.lang.Exception |
If you specify a name for the form field, then a bookmark is automatically created with the same name.
name
- The name of the form field. Can be an empty string.defaultValue
- Default value of the form field.size
- Specifies the size of the checkbox in points. Specify 0 for MS Word
to calculate the size of the checkbox automatically.Example:
Shows how to insert checkbox form fields into a document during mail merge.// File 'MailMerge.InsertCheckBox.doc' is a template // containing the table with the following fields in it: // <<TableStart:StudentCourse>> <<CourseName>> <<TableEnd:StudentCourse>>. public void mailMergeInsertCheckBox() throws Exception { Document doc = new Document(getMyDir() + "MailMerge.InsertCheckBox.doc"); // Add a hadler for the MergeField event. doc.getMailMerge().addMergeFieldEventHandler(new HandleMergeFieldInsertCheckBox()); // Execute mail merge with regions. mCheckBoxCount = 0; StudentCourseDataTable dataTable = getStudentCourseDataTable(); doc.getMailMerge().executeWithRegions(dataTable); // Save resulting document with a new name. doc.save(getMyDir() + "MailMerge.InsertCheckBox Out.doc"); } /// <summary> /// Counter for CheckBox name generation /// </summary> private int mCheckBoxCount; /// <summary> /// This is called for each merge field in the document /// when Document.MailMerge.ExecuteWithRegions is called. /// </summary> private class HandleMergeFieldInsertCheckBox implements MergeFieldEventHandler { public void mergeField(Object sender, MergeFieldEventArgs e) throws Exception { if ("CourseName".equals(e.getDocumentFieldName())) { // Insert the checkbox for this merge field, using DocumentBuilder. DocumentBuilder builder = new DocumentBuilder(e.getDocument()); builder.moveToMergeField(e.getFieldName()); builder.insertCheckBox(e.getDocumentFieldName() + mCheckBoxCount, false, 0); builder.write((String)e.getFieldValue()); mCheckBoxCount++; } } } /// <summary> /// Create DataTable and fill it with data. /// In real life this DataTable should be filled from a database. /// </summary> private StudentCourseDataTable getStudentCourseDataTable() { ArrayList data = new ArrayList(); for (int i = 0; i < 10; i++) data.add("Course " + i); return new StudentCourseDataTable(data); } /// <summary> /// This is a simple implementation of a custom mail merge data source over an ArrayList. /// </summary> public class StudentCourseDataTable implements IMailMergeDataSource { private ArrayList mData; private int mRecordIndex; public StudentCourseDataTable(ArrayList data) { mData = data; // When the data source is initialized, it must be positioned before the first record. mRecordIndex= -1; } /// <summary> /// The name of the data source. Used by Aspose.Words only when executing mail merge with repeatable regions. /// </summary> public String getTableName() { return "StudentCourse"; } /// <summary> /// Aspose.Words calls this to get a value for every data field. /// </summary> public boolean getValue(String fieldName, Object[] fieldValue) { if ("CourseName".equals(fieldName)) { fieldValue[0] = mData.get(mRecordIndex); return true; } else { // A field with this name was not found, return false to the Aspose.Words mail merge engine. fieldValue[0] = null; return false; } } /// <summary> /// A standard implementation for moving to a next record in a collection. /// </summary> public boolean moveNext() { if (!isEof()) mRecordIndex++; return (!isEof()); } private boolean isEof() { return (mRecordIndex >= mData.size()); } }
Example:
Builds a sample form to fill.DocumentBuilder builder = new DocumentBuilder(); // Insert a text form field for input a name. builder.insertTextInput("", TextFormFieldType.REGULAR_TEXT, "", "Enter your name here", 30); // Insert 2 blank lines. builder.writeln(""); builder.writeln(""); String[] items = new String[] { "-- Select your favorite footwear --", "Sneakers", "Oxfords", "Flip-flops", "Other", "I prefer to be barefoot" }; // Insert a combo box to select a footwear type. builder.insertComboBox("", items, 0); // Insert 2 blank lines. builder.writeln(""); builder.writeln(""); // Insert a check box to ensure the form filler does look after his/her footwear. builder.insertCheckBox("", true, 0); builder.writeln("My boots are always polished and nice-looking."); builder.getDocument().save(getMyDir() + "DocumentBuilder.CreateForm Out.doc");
insertComboBox | |
public FormField insertComboBox(java.lang.String name, java.lang.String[] items, int selectedIndex) throws java.lang.Exception |
If you specify a name for the form field, then a bookmark is automatically created with the same name.
name
- The name of the form field. Can be an empty string.items
- The items of the combobox. Maximum is 25 items.selectedIndex
- The index of the selected item in the combobox.Example:
Builds a sample form to fill.DocumentBuilder builder = new DocumentBuilder(); // Insert a text form field for input a name. builder.insertTextInput("", TextFormFieldType.REGULAR_TEXT, "", "Enter your name here", 30); // Insert 2 blank lines. builder.writeln(""); builder.writeln(""); String[] items = new String[] { "-- Select your favorite footwear --", "Sneakers", "Oxfords", "Flip-flops", "Other", "I prefer to be barefoot" }; // Insert a combo box to select a footwear type. builder.insertComboBox("", items, 0); // Insert 2 blank lines. builder.writeln(""); builder.writeln(""); // Insert a check box to ensure the form filler does look after his/her footwear. builder.insertCheckBox("", true, 0); builder.writeln("My boots are always polished and nice-looking."); builder.getDocument().save(getMyDir() + "DocumentBuilder.CreateForm Out.doc");
insertFootnote | |
public Footnote insertFootnote(int footnoteType, java.lang.String footnoteText) throws java.lang.Exception |
footnoteType
- A footnoteText
- Specifies the text of the footnote.insertImage | |
public Shape insertImage(java.awt.image.BufferedImage image) throws java.lang.Exception |
You can change the image size, location, positioning method and other settings using the
Note: The image inserted in PNG format with default
image
- The image to insert into the document.Example:
Inserts a watermark image into a document using DocumentBuilder.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // The best place for the watermark image is in the header or footer so it is shown on every page. builder.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY); // Insert a floating picture. BufferedImage image = javax.imageio.ImageIO.read(new File(getMyDir() + "Watermark.png")); Shape shape = builder.insertImage(image); shape.setWrapType(WrapType.NONE); shape.setBehindText(true); shape.setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE); shape.setRelativeVerticalPosition(RelativeVerticalPosition.PAGE); // Calculate image left and top position so it appears in the centre of the page. shape.setLeft((builder.getPageSetup().getPageWidth() - shape.getWidth()) / 2); shape.setTop((builder.getPageSetup().getPageHeight() - shape.getHeight()) / 2); doc.save(getMyDir() + "DocumentBuilder.InsertWatermark Out.doc");
Example:
Shows how to insert a BufferedImage and byte[] object into a document. The image is inserted inline and at 100% scale.// This creates a builder and also an empty document inside the builder. DocumentBuilder builder = new DocumentBuilder(); // Insert a raster image. BufferedImage rasterImage = javax.imageio.ImageIO.read(new File(getMyDir() + "Aspose.Words.gif")); builder.write("Raster image: "); builder.insertImage(rasterImage); builder.writeln(); // Aspose.Words allows to insert a metafile images too. // Core Java does not allow to load metafiles into BufferedImage, therefore we use another overload. FileInputStream stream = new FileInputStream( getMyDir() + "Hammer.wmf"); byte metafile[] = new byte[stream.available()]; stream.read(metafile, 0, metafile.length); stream.close(); builder.write("Metafile: "); builder.insertImage(metafile); builder.writeln(); builder.getDocument().save(getMyDir() + "Image.CreateFromImage Out.doc");
insertImage | |
public Shape insertImage(java.lang.String fileName) throws java.lang.Exception |
This overload will automatically download the image before inserting into the document if you specify a remote URI.
You can change the image size, location, positioning method and other settings using the
fileName
- The file with the image. Can be any valid local or remote URI.Example:
Shows how to insert a floating image in the middle of a page.// This creates a builder and also an empty document inside the builder. DocumentBuilder builder = new DocumentBuilder(); // By default, the image is inline. Shape shape = builder.insertImage(getMyDir() + "Aspose.Words.gif"); // Make the image float, put it behind text and center on the page. shape.setWrapType(WrapType.NONE); shape.setBehindText(true); shape.setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE); shape.setHorizontalAlignment(HorizontalAlignment.CENTER); shape.setRelativeVerticalPosition(RelativeVerticalPosition.PAGE); shape.setVerticalAlignment(VerticalAlignment.CENTER); builder.getDocument().save(getMyDir() + "Image.CreateFloatingPageCenter Out.doc");
Example:
Shows how to inserts an image from a url. The image is inserted inline and at 100% scale.// This creates a builder and also an empty document inside the builder. DocumentBuilder builder = new DocumentBuilder(); builder.write("Image from local file: "); builder.insertImage(getMyDir() + "Aspose.Words.gif"); builder.writeln(); builder.write("Image from an internet url, automatically downloaded for you: "); builder.insertImage("http://www.aspose.com/Images/aspose-logo.jpg"); builder.writeln(); builder.getDocument().save(getMyDir() + "Image.CreateFromUrl Out.doc");
insertImage | |
public Shape insertImage(java.io.InputStream stream) throws java.lang.Exception |
You can change the image size, location, positioning method and other settings using the
stream
- The stream that contains the image.
The stream will be read from the current position, so one should be careful about stream position.Example:
Shows how to insert an image from a stream. The image is inserted inline and at 100% scale.// This creates a builder and also an empty document inside the builder. DocumentBuilder builder = new DocumentBuilder(); InputStream stream=new FileInputStream(getMyDir() + "Aspose.Words.gif"); try { builder.write("Image from stream: "); builder.insertImage(stream); } finally { stream.close(); } builder.getDocument().save(getMyDir() + "Image.CreateFromStream Out.doc");
insertImage | |
public Shape insertImage(byte[] imageBytes) throws java.lang.Exception |
You can change the image size, location, positioning method and other settings using the
imageBytes
- The byte array that contains the image.Example:
Shows how to insert a BufferedImage and byte[] object into a document. The image is inserted inline and at 100% scale.// This creates a builder and also an empty document inside the builder. DocumentBuilder builder = new DocumentBuilder(); // Insert a raster image. BufferedImage rasterImage = javax.imageio.ImageIO.read(new File(getMyDir() + "Aspose.Words.gif")); builder.write("Raster image: "); builder.insertImage(rasterImage); builder.writeln(); // Aspose.Words allows to insert a metafile images too. // Core Java does not allow to load metafiles into BufferedImage, therefore we use another overload. FileInputStream stream = new FileInputStream( getMyDir() + "Hammer.wmf"); byte metafile[] = new byte[stream.available()]; stream.read(metafile, 0, metafile.length); stream.close(); builder.write("Metafile: "); builder.insertImage(metafile); builder.writeln(); builder.getDocument().save(getMyDir() + "Image.CreateFromImage Out.doc");
insertImage | |
public Shape insertImage(java.awt.image.BufferedImage image, double width, double height) throws java.lang.Exception |
You can change the image size, location, positioning method and other settings using the
Note: The image inserted in PNG format with default
image
- The image to insert into the document.width
- The width of the image in points. Can be a negative value to request 100% scale.height
- The height if the image in points. Can be a negative value to request 100% scale.insertImage | |
public Shape insertImage(java.lang.String fileName, double width, double height) throws java.lang.Exception |
You can change the image size, location, positioning method and other settings using the
fileName
- The file that contains the image.width
- The width of the image in points. Can be a negative value to request 100% scale.height
- The height if the image in points. Can be a negative value to request 100% scale.insertImage | |
public Shape insertImage(java.io.InputStream stream, double width, double height) throws java.lang.Exception |
You can change the image size, location, positioning method and other settings using the
stream
- The stream that contains the image.width
- The width of the image in points. Can be a negative value to request 100% scale.height
- The height if the image in points. Can be a negative value to request 100% scale.insertImage | |
public Shape insertImage(byte[] imageBytes, double width, double height) throws java.lang.Exception |
You can change the image size, location, positioning method and other settings using the
imageBytes
- The byte array that contains the image.width
- The width of the image in points. Can be a negative value to request 100% scale.height
- The height if the image in points. Can be a negative value to request 100% scale.insertImage | |
public Shape insertImage(java.awt.image.BufferedImage image, int horzPos, double left, int vertPos, double top, double width, double height, int wrapType) throws java.lang.Exception |
You can change the image size, location, positioning method and other settings using the
Note: The image inserted in PNG format with default
image
- The image to insert into the document.horzPos
- A left
- Distance in points from the origin to the left side of the image.vertPos
- A top
- Distance in points from the origin to the top side of the image.width
- The width of the image in points. Can be a negative value to request 100% scale.height
- The height if the image in points. Can be a negative value to request 100% scale.wrapType
- A insertImage | |
public Shape insertImage(java.lang.String fileName, int horzPos, double left, int vertPos, double top, double width, double height, int wrapType) throws java.lang.Exception |
You can change the image size, location, positioning method and other settings using the
fileName
- The file that contains the image.horzPos
- A left
- Distance in points from the origin to the left side of the image.vertPos
- A top
- Distance in points from the origin to the top side of the image.width
- The width of the image in points. Can be a negative value to request 100% scale.height
- The height if the image in points. Can be a negative value to request 100% scale.wrapType
- A insertImage | |
public Shape insertImage(java.io.InputStream stream, int horzPos, double left, int vertPos, double top, double width, double height, int wrapType) throws java.lang.Exception |
You can change the image size, location, positioning method and other settings using the
stream
- The stream that contains the image.horzPos
- A left
- Distance in points from the origin to the left side of the image.vertPos
- A top
- Distance in points from the origin to the top side of the image.width
- The width of the image in points. Can be a negative value to request 100% scale.height
- The height if the image in points. Can be a negative value to request 100% scale.wrapType
- A insertImage | |
public Shape insertImage(byte[] imageBytes, int horzPos, double left, int vertPos, double top, double width, double height, int wrapType) throws java.lang.Exception |
You can change the image size, location, positioning method and other settings using the
imageBytes
- The byte array that contains the image.horzPos
- A left
- Distance in points from the origin to the left side of the image.vertPos
- A top
- Distance in points from the origin to the top side of the image.width
- The width of the image in points. Can be a negative value to request 100% scale.height
- The height if the image in points. Can be a negative value to request 100% scale.wrapType
- A insertHtml | |
public void insertHtml(java.lang.String html) throws java.lang.Exception |
You can use InsertHtml to insert an HTML fragment or whole HTML document.
html
- HTML string to insert into the document.Example:
Shows how to mail merge HTML data into a document.// File 'MailMerge.InsertHtml.doc' has merge field named 'htmlField1' in it. // File 'MailMerge.HtmlData.html' contains some valid Html data. // The same approach can be used when merging HTML data from database. public void mergeHtml() throws Exception { Document doc = new Document(getMyDir() + "MailMerge.InsertHtml.doc"); // Add a hadler for the MergeField event. doc.getMailMerge().addMergeFieldEventHandler(new HandleMergeFieldInsertHtml()); // Load some Html from file. FileReader fileReader = new FileReader(getMyDir() + "MailMerge.HtmlData.html"); BufferedReader buffReader = new BufferedReader(fileReader); String temp = ""; String htmltext = ""; while ((temp = buffReader.readLine()) != null) htmltext += temp; buffReader.close(); // Execute mail merge. doc.getMailMerge().execute(new String[] {"htmlField1"}, new String[] {htmltext}); // Save resulting document with a new name. doc.save(getMyDir() + "MailMerge.InsertHtml Out.doc"); } /// <summary> /// This is called when merge field is actually merged with data in the document. /// </summary> private class HandleMergeFieldInsertHtml implements MergeFieldEventHandler { public void mergeField(Object sender, MergeFieldEventArgs e) throws Exception { // All merge fields that expect HTML data should be marked with some prefix, e.g. 'html'. if (e.getDocumentFieldName().startsWith("html")) { // Insert the text for this merge field as HTML data, using DocumentBuilder. DocumentBuilder builder = new DocumentBuilder(e.getDocument()); builder.moveToMergeField(e.getDocumentFieldName()); builder.insertHtml((String)e.getFieldValue()); // The HTML text itself should not be inserted. // We have already inserted it as an HTML. e.setText(""); } } }
Example:
Replaces text specified with regular expression with HTML.public void replaceWithInsertHtml() throws Exception { // Open the document. Document doc = new Document(getMyDir() + "Range.ReplaceWithInsertHtml.doc"); doc.getRange().replace(Pattern.compile("<CustomerName>"), new ReplaceWithHtmlEvaluator(), false); // Save the modified document. doc.save(getMyDir() + "Range.ReplaceWithInsertHtml Out.doc"); } private class ReplaceWithHtmlEvaluator implements ReplaceEvaluator { /** * A user implemented ReplaceEvaluator.replace() method is called for each * match found during a replace operation. * * NOTE: This is a simplistic method that will only work well when the match * starts at the beginning of a run. * * @return An enumerated value that specifies the action to be taken for the current match. */ public int replace(Object sender, ReplaceEvaluatorArgs e) throws Exception { DocumentBuilder builder = new DocumentBuilder((Document) e.getMatchNode().getDocument()); builder.moveTo(e.getMatchNode()); // Replace '<CustomerName>' text with a red bold name. builder.insertHtml("<b><font color='red'>James Bond</font></b>"); e.setReplacement(""); return ReplaceAction.REPLACE; } }
Example:
Inserts HTML into a document using DocumentBuilder.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.insertHtml( "<P align='right'>Paragraph right</P>" + "<b>Implicit paragraph left</b>" + "<div align='center'>Div center</div>" + "<h1 align='left'>Heading 1 left.</h1>"); doc.save(getMyDir() + "DocumentBuilder.InsertHtml Out.doc");
insertCell | |
public Cell insertCell() throws java.lang.Exception |
To start a table, just call InsertCell. After this, any content you add using
other methods of the
To start a new cell in the same row, call InsertCell again.
To end a table row call
Use the
Example:
Creates a table with two columns with cells merged vertically in the first column.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.insertCell(); builder.getCellFormat().setVerticalMerge(CellMerge.FIRST); builder.write("Text in the merged cells."); builder.insertCell(); builder.getCellFormat().setVerticalMerge(CellMerge.NONE); builder.write("Text in one cell"); builder.endRow(); builder.insertCell(); // This cell is vertically merged to the cell above and should be empty. builder.getCellFormat().setVerticalMerge(CellMerge.PREVIOUS); builder.insertCell(); builder.getCellFormat().setVerticalMerge(CellMerge.NONE); builder.write("Text in another cell"); builder.endRow();
startTable | |
public Table startTable() throws java.lang.Exception |
The next method to call is
This method starts a nested table when called inside a cell.
endTable | |
public Table endTable() throws java.lang.Exception |
This method should be called only once after
endRow | |
public Row endRow() throws java.lang.Exception |
Call EndRow to end a table row. If you call
Use the
Example:
Creates a table with two columns with cells merged vertically in the first column.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.insertCell(); builder.getCellFormat().setVerticalMerge(CellMerge.FIRST); builder.write("Text in the merged cells."); builder.insertCell(); builder.getCellFormat().setVerticalMerge(CellMerge.NONE); builder.write("Text in one cell"); builder.endRow(); builder.insertCell(); // This cell is vertically merged to the cell above and should be empty. builder.getCellFormat().setVerticalMerge(CellMerge.PREVIOUS); builder.insertCell(); builder.getCellFormat().setVerticalMerge(CellMerge.NONE); builder.write("Text in another cell"); builder.endRow();
startBookmark | |
public BookmarkStart startBookmark(java.lang.String bookmarkName) throws java.lang.Exception |
Bookmarks in a document can overlap and span any range. To create a valid bookmark you need to
call both
Badly formed bookmarks or bookmarks with duplicate names will be ignored when the document is saved.
bookmarkName
- Name of the bookmark.Example:
Inserts a hyperlink referencing local bookmark.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.startBookmark("Bookmark1"); builder.write("Bookmarked text."); builder.endBookmark("Bookmark1"); builder.writeln("Some other text"); // Specify font formatting for the hyperlink. builder.getFont().setColor(Color.BLUE); builder.getFont().setUnderline(Underline.SINGLE); // Insert hyperlink. // Switch \o is used to provide hyperlink tip text. builder.insertHyperlink("Hyperlink Text", "Bookmark1\" \\o \"Hyperlink Tip", true); // Clear hyperlink formatting. builder.getFont().clearFormatting(); doc.save(getMyDir() + "DocumentBuilder.InsertHyperlinkToLocalBookmark Out.doc");
Example:
Adds some text into the document and encloses the text in a bookmark using DocumentBuilder.DocumentBuilder builder = new DocumentBuilder(); builder.startBookmark("MyBookmark"); builder.writeln("Text inside a bookmark."); builder.endBookmark("MyBookmark");
endBookmark | |
public BookmarkEnd endBookmark(java.lang.String bookmarkName) throws java.lang.Exception |
Bookmarks in a document can overlap and span any range. To create a valid bookmark you need to
call both
Badly formed bookmarks or bookmarks with duplicate names will be ignored when the document is saved.
bookmarkName
- Name of the bookmark.Example:
Inserts a hyperlink referencing local bookmark.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.startBookmark("Bookmark1"); builder.write("Bookmarked text."); builder.endBookmark("Bookmark1"); builder.writeln("Some other text"); // Specify font formatting for the hyperlink. builder.getFont().setColor(Color.BLUE); builder.getFont().setUnderline(Underline.SINGLE); // Insert hyperlink. // Switch \o is used to provide hyperlink tip text. builder.insertHyperlink("Hyperlink Text", "Bookmark1\" \\o \"Hyperlink Tip", true); // Clear hyperlink formatting. builder.getFont().clearFormatting(); doc.save(getMyDir() + "DocumentBuilder.InsertHyperlinkToLocalBookmark Out.doc");
Example:
Adds some text into the document and encloses the text in a bookmark using DocumentBuilder.DocumentBuilder builder = new DocumentBuilder(); builder.startBookmark("MyBookmark"); builder.writeln("Text inside a bookmark."); builder.endBookmark("MyBookmark");
pushFont | |
public void pushFont() throws java.lang.Exception |
Example:
Shows how to use temporarily save and restore character formatting when building a document with DocumentBuilder.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Set up font formatting and write text that goes before the hyperlink. builder.getFont().setName("Arial"); builder.getFont().setSize(24); builder.getFont().setBold(true); builder.write("To go to an important location, click "); // Save the font formatting so we use different formatting for hyperlink and restore old formatting later. builder.pushFont(); // Set new font formatting for the hyperlink and insert the hyperlink. // The "Hyperlink" style is a Microsoft Word built-in style so we don't have to worry to // create it, it will be created automatically if it does not yet exist in the document. builder.getFont().setStyleIdentifier(StyleIdentifier.HYPERLINK); builder.insertHyperlink("here", "http://www.google.com", false); // Restore the formatting that was before the hyperlink. builder.popFont(); builder.writeln(". We hope you enjoyed the example."); doc.save(getMyDir() + "DocumentBuilder.PushPopFont Out.doc");
popFont | |
public void popFont() throws java.lang.Exception |
Example:
Shows how to use temporarily save and restore character formatting when building a document with DocumentBuilder.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Set up font formatting and write text that goes before the hyperlink. builder.getFont().setName("Arial"); builder.getFont().setSize(24); builder.getFont().setBold(true); builder.write("To go to an important location, click "); // Save the font formatting so we use different formatting for hyperlink and restore old formatting later. builder.pushFont(); // Set new font formatting for the hyperlink and insert the hyperlink. // The "Hyperlink" style is a Microsoft Word built-in style so we don't have to worry to // create it, it will be created automatically if it does not yet exist in the document. builder.getFont().setStyleIdentifier(StyleIdentifier.HYPERLINK); builder.insertHyperlink("here", "http://www.google.com", false); // Restore the formatting that was before the hyperlink. builder.popFont(); builder.writeln(". We hope you enjoyed the example."); doc.save(getMyDir() + "DocumentBuilder.PushPopFont Out.doc");
insertNode | |
public void insertNode(Node node) throws java.lang.Exception |
Example:
Shows how to insert a linked image into a document.DocumentBuilder builder = new DocumentBuilder(); String imageFileName = getMyDir() + "Hammer.wmf"; builder.write("Image linked, not stored in the document: "); Shape linkedOnly = new Shape(builder.getDocument(), ShapeType.IMAGE); linkedOnly.setWrapType(WrapType.INLINE); linkedOnly.getImageData().setSourceFullName(imageFileName); builder.insertNode(linkedOnly); builder.writeln(); builder.write("Image linked and stored in the document: "); Shape linkedAndStored = new Shape(builder.getDocument(), ShapeType.IMAGE); linkedAndStored.setWrapType(WrapType.INLINE); linkedAndStored.getImageData().setSourceFullName(imageFileName); linkedAndStored.getImageData().setImage(imageFileName); builder.insertNode(linkedAndStored); builder.writeln(); builder.write("Image stored in the document, but not linked: "); Shape stored = new Shape(builder.getDocument(), ShapeType.IMAGE); stored.setWrapType(WrapType.INLINE); stored.getImageData().setImage(imageFileName); builder.insertNode(stored); builder.writeln(); builder.getDocument().save(getMyDir() + "Image.CreateLinkedImage Out.doc");
getDirectRunAttr | |
public java.lang.Object getDirectRunAttr(int fontAttr) |
getDirectRunAttrsCount | |
public int getDirectRunAttrsCount() |
getDirectRunAttrByIndex | |
public void getDirectRunAttrByIndex(int index, int[] key, java.lang.Object[] value) |
fetchInheritedRunAttr | |
public java.lang.Object fetchInheritedRunAttr(int fontAttr) throws java.lang.Exception |
setRunAttr | |
public void setRunAttr(int fontAttr, java.lang.Object value) |
clearRunAttrs | |
public void clearRunAttrs() |
getDirectRowAttr | |
public java.lang.Object getDirectRowAttr(int key) |
fetchInheritedRowAttr | |
public java.lang.Object fetchInheritedRowAttr(int key) throws java.lang.Exception |
setRowAttr | |
public void setRowAttr(int key, java.lang.Object value) |
clearRowAttrs | |
public void clearRowAttrs() |
getDirectCellAttr | |
public java.lang.Object getDirectCellAttr(int key) |
fetchInheritedCellAttr | |
public java.lang.Object fetchInheritedCellAttr(int key) throws java.lang.Exception |
setCellAttr | |
public void setCellAttr(int key, java.lang.Object value) |
clearCellAttrs | |
public void clearCellAttrs() |