public class Table extends CompositeNode
Table is a block-level node and can be a child of classes derived from Story or InlineStory.
Table can contain one or more Row nodes.
A minimal valid table needs to have at least one Row.
| Constructor and Description |
|---|
Table(DocumentBase doc)
Initializes a new instance of the Table class.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
accept(DocumentVisitor visitor)
Accepts a visitor.
|
void |
autoFit(int behavior) |
void |
clearBorders()
Removes all table and cell borders on this table.
|
void |
clearShading()
Removes all shading on the table.
|
void |
convertToHorizontallyMergedCells()
Converts cells horizontally merged by width to cells merged by
CellFormat.getHorizontalMerge() / CellFormat.setHorizontalMerge(int). |
void |
ensureMinimum()
If the table has no rows, creates and appends one Row.
|
double |
getAbsoluteHorizontalDistance()
Gets absolute horizontal floating table position specified by the table properties, in points.
|
double |
getAbsoluteVerticalDistance()
Gets absolute vertical floating table position specified by the table properties, in points.
|
int |
getAlignment()
Specifies how an inline table is aligned in the document.
|
boolean |
getAllowAutoFit()
Allows Microsoft Word and Aspose.Words to automatically resize cells in a table to fit their contents.
|
boolean |
getAllowCellSpacing()
Gets the "Allow spacing between cells" option.
|
boolean |
getAllowOverlap()
Gets whether a floating table shall allow other floating objects in the document to overlap its extents when displayed.
|
boolean |
getBidi()
Gets whether this is a right-to-left table.
|
double |
getBottomPadding()
Gets the amount of space (in points) to add below the contents of cells.
|
double |
getCellSpacing()
Gets the amount of space (in points) between the cells.
|
java.lang.String |
getDescription()
Gets description of this table.
|
double |
getDistanceBottom()
Gets distance between table bottom and the surrounding text, in points.
|
double |
getDistanceLeft()
Gets distance between table left and the surrounding text, in points.
|
double |
getDistanceRight()
Gets distance between table right and the surrounding text, in points.
|
double |
getDistanceTop()
Gets distance between table top and the surrounding text, in points.
|
Row |
getFirstRow()
Returns the first Row node in the table.
|
int |
getHorizontalAnchor()
Gets the base object from which the horizontal positioning of floating table should be calculated.
|
Row |
getLastRow()
Returns the last Row node in the table.
|
double |
getLeftIndent()
Gets the value that represents the left indent of the table.
|
double |
getLeftPadding()
Gets the amount of space (in points) to add to the left of the contents of cells.
|
int |
getNodeType()
Returns NodeType.Table.
|
PreferredWidth |
getPreferredWidth()
Gets the table preferred width.
|
int |
getRelativeHorizontalAlignment()
Gets floating table relative horizontal alignment.
|
int |
getRelativeVerticalAlignment()
Gets floating table relative vertical alignment.
|
double |
getRightPadding()
Gets the amount of space (in points) to add to the right of the contents of cells.
|
RowCollection |
getRows()
Provides typed access to the rows of the table.
|
Style |
getStyle()
Gets the table style applied to this table.
|
int |
getStyleIdentifier()
Gets the locale independent style identifier of the table style applied to this table.
|
java.lang.String |
getStyleName()
Gets the name of the table style applied to this table.
|
int |
getStyleOptions()
Gets bit flags that specify how a table style is applied to this table.
|
int |
getTextWrapping()
Gets
getTextWrapping() / setTextWrapping(int) for table. |
java.lang.String |
getTitle()
Gets title of this table.
|
double |
getTopPadding()
Gets the amount of space (in points) to add above the contents of cells.
|
int |
getVerticalAnchor()
Gets the base object from which the vertical positioning of floating table should be calculated.
|
void |
setAbsoluteHorizontalDistance(double value)
Sets absolute horizontal floating table position specified by the table properties, in points.
|
void |
setAbsoluteVerticalDistance(double value)
Sets absolute vertical floating table position specified by the table properties, in points.
|
void |
setAlignment(int value)
Specifies how an inline table is aligned in the document.
|
void |
setAllowAutoFit(boolean value)
Allows Microsoft Word and Aspose.Words to automatically resize cells in a table to fit their contents.
|
void |
setAllowCellSpacing(boolean value)
Sets the "Allow spacing between cells" option.
|
void |
setBidi(boolean value)
Sets whether this is a right-to-left table.
|
void |
setBorder(int borderType,
int lineStyle,
double lineWidth,
java.awt.Color color,
boolean isOverrideCellBorders) |
void |
setBorders(int lineStyle,
double lineWidth,
java.awt.Color color) |
void |
setBottomPadding(double value)
Sets the amount of space (in points) to add below the contents of cells.
|
void |
setCellSpacing(double value)
Sets the amount of space (in points) between the cells.
|
void |
setDescription(java.lang.String value)
Sets description of this table.
|
void |
setHorizontalAnchor(int value)
Gets the base object from which the horizontal positioning of floating table should be calculated.
|
void |
setLeftIndent(double value)
Sets the value that represents the left indent of the table.
|
void |
setLeftPadding(double value)
Sets the amount of space (in points) to add to the left of the contents of cells.
|
void |
setPreferredWidth(PreferredWidth value)
Sets the table preferred width.
|
void |
setRelativeHorizontalAlignment(int value)
Sets floating table relative horizontal alignment.
|
void |
setRelativeVerticalAlignment(int value)
Sets floating table relative vertical alignment.
|
void |
setRightPadding(double value)
Sets the amount of space (in points) to add to the right of the contents of cells.
|
void |
setShading(int texture,
java.awt.Color foregroundColor,
java.awt.Color backgroundColor) |
void |
setStyle(Style value)
Sets the table style applied to this table.
|
void |
setStyleIdentifier(int value)
Sets the locale independent style identifier of the table style applied to this table.
|
void |
setStyleName(java.lang.String value)
Sets the name of the table style applied to this table.
|
void |
setStyleOptions(int value)
Sets bit flags that specify how a table style is applied to this table.
|
void |
setTextWrapping(int value)
Sets
getTextWrapping() / setTextWrapping(int) for table. |
void |
setTitle(java.lang.String value)
Sets title of this table.
|
void |
setTopPadding(double value)
Sets the amount of space (in points) to add above the contents of cells.
|
void |
setVerticalAnchor(int value)
Gets the base object from which the vertical positioning of floating table should be calculated.
|
acceptChildren, acceptCore, appendChild, coreRemoveSelfOnly, getChild, getChildNodes, getChildNodes, getContainer, getCount, getCurrentNode, getFirstChild, getLastChild, getNextMatchingNode, getText, hasChildNodes, indexOf, insertAfter, insertBefore, isComposite, iterator, prependChild, removeAllChildren, removeChild, removeSmartTags, selectNodes, selectSingleNodedd, deepClone, getAncestor, getAncestor, getCustomNodeId, getDocument, getNextSibling, getParentNode, getPreviousSibling, getRange, memberwiseClone, nextPreOrder, nodeTypeToString, previousPreOrder, remove, setCustomNodeId, toString, toString, toString, visitorActionToBoolpublic Table(DocumentBase doc)
When Table is created, it belongs to the specified document, but is not yet part of the document and ParentNode is null.
To append Table to the document use InsertAfter or InsertBefore on the story where you want the table inserted.
doc - The owner document.public void convertToHorizontallyMergedCells()
CellFormat.getHorizontalMerge() / CellFormat.setHorizontalMerge(int).
Table cells can be horizontally merged either using merge flags CellFormat.getHorizontalMerge() / CellFormat.setHorizontalMerge(int) or using cell width CellFormat.getWidth() / CellFormat.setWidth(double).
When table cell is merged by width property CellFormat.getHorizontalMerge() / CellFormat.setHorizontalMerge(int) is meaningless but sometimes having merge flags is more convenient way.
Use this method to transforms table cells horizontally merged by width to cells merged by merge flags.
public int getNodeType()
getNodeType in class NodeNodeType constants.public Row getFirstRow()
public Row getLastRow()
public RowCollection getRows()
RowCollection value.public boolean accept(DocumentVisitor visitor) throws java.lang.Exception
Enumerates over this node and all of its children. Each node calls a corresponding method on DocumentVisitor.
For more info see the Visitor design pattern.
public void ensureMinimum()
public int getAlignment()
The default value is TableAlignment.LEFT.
int value. The returned value is one of TableAlignment constants.public void setAlignment(int value)
throws java.lang.Exception
The default value is TableAlignment.LEFT.
value - The corresponding int value. The value must be one of TableAlignment constants.java.lang.Exceptionpublic boolean getAllowAutoFit()
The default value is true.
boolean value.public void setAllowAutoFit(boolean value)
throws java.lang.Exception
The default value is true.
value - The corresponding boolean value.java.lang.Exceptionpublic PreferredWidth getPreferredWidth()
The default value is PreferredWidth.AUTO.
public void setPreferredWidth(PreferredWidth value) throws java.lang.Exception
The default value is PreferredWidth.AUTO.
value - The table preferred width.java.lang.Exceptionpublic boolean getBidi()
When true, the cells in this row are laid out right to left.
The default value is false.
public void setBidi(boolean value)
throws java.lang.Exception
When true, the cells in this row are laid out right to left.
The default value is false.
value - Whether this is a right-to-left table.java.lang.Exceptionpublic double getLeftPadding()
public void setLeftPadding(double value)
throws java.lang.Exception
value - The amount of space (in points) to add to the left of the contents of cells.java.lang.Exceptionpublic double getRightPadding()
public void setRightPadding(double value)
throws java.lang.Exception
value - The amount of space (in points) to add to the right of the contents of cells.java.lang.Exceptionpublic double getTopPadding()
public void setTopPadding(double value)
throws java.lang.Exception
value - The amount of space (in points) to add above the contents of cells.java.lang.Exceptionpublic double getBottomPadding()
public void setBottomPadding(double value)
throws java.lang.Exception
value - The amount of space (in points) to add below the contents of cells.java.lang.Exceptionpublic double getCellSpacing()
public void setCellSpacing(double value)
throws java.lang.Exception
value - The amount of space (in points) between the cells.java.lang.Exceptionpublic boolean getAllowCellSpacing()
public void setAllowCellSpacing(boolean value)
throws java.lang.Exception
value - The "Allow spacing between cells" option.java.lang.Exceptionpublic double getLeftIndent()
public void setLeftIndent(double value)
throws java.lang.Exception
value - The value that represents the left indent of the table.java.lang.Exceptionpublic int getStyleOptions()
TableStyleOptions constants.public void setStyleOptions(int value)
throws java.lang.Exception
value - Bit flags that specify how a table style is applied to this table. The value must be a bitwise combination of TableStyleOptions constants.java.lang.Exceptionpublic Style getStyle()
public void setStyle(Style value) throws java.lang.Exception
value - The table style applied to this table.java.lang.Exceptionpublic java.lang.String getStyleName()
public void setStyleName(java.lang.String value)
throws java.lang.Exception
value - The name of the table style applied to this table.java.lang.Exceptionpublic int getStyleIdentifier()
StyleIdentifier constants.public void setStyleIdentifier(int value)
throws java.lang.Exception
value - The locale independent style identifier of the table style applied to this table. The value must be one of StyleIdentifier constants.java.lang.Exceptionpublic int getTextWrapping()
getTextWrapping() / setTextWrapping(int) for table.getTextWrapping() / setTextWrapping(int) for table. The returned value is one of TextWrapping constants.public void setTextWrapping(int value)
throws java.lang.Exception
getTextWrapping() / setTextWrapping(int) for table.value - getTextWrapping() / setTextWrapping(int) for table. The value must be one of TextWrapping constants.java.lang.Exceptionpublic java.lang.String getTitle()
The default value is an empty string.
This property is meaningful for ISO/IEC 29500 compliant DOCX documents ( OoxmlCompliance). When saved to pre-ISO/IEC 29500 formats, the property is ignored.
public void setTitle(java.lang.String value)
throws java.lang.Exception
The default value is an empty string.
This property is meaningful for ISO/IEC 29500 compliant DOCX documents ( OoxmlCompliance). When saved to pre-ISO/IEC 29500 formats, the property is ignored.
value - Title of this table.java.lang.Exceptionpublic java.lang.String getDescription()
The default value is an empty string.
This property is meaningful for ISO/IEC 29500 compliant DOCX documents ( OoxmlCompliance). When saved to pre-ISO/IEC 29500 formats, the property is ignored.
public void setDescription(java.lang.String value)
throws java.lang.Exception
The default value is an empty string.
This property is meaningful for ISO/IEC 29500 compliant DOCX documents ( OoxmlCompliance). When saved to pre-ISO/IEC 29500 formats, the property is ignored.
value - Description of this table.java.lang.Exceptionpublic double getDistanceLeft()
public double getDistanceRight()
public double getDistanceTop()
public double getDistanceBottom()
public int getRelativeHorizontalAlignment()
HorizontalAlignment constants.public void setRelativeHorizontalAlignment(int value)
throws java.lang.Exception
value - Floating table relative horizontal alignment. The value must be one of HorizontalAlignment constants.java.lang.Exceptionpublic int getRelativeVerticalAlignment()
VerticalAlignment constants.public void setRelativeVerticalAlignment(int value)
throws java.lang.Exception
value - Floating table relative vertical alignment. The value must be one of VerticalAlignment constants.java.lang.Exceptionpublic int getHorizontalAnchor()
RelativeHorizontalPosition.COLUMN.RelativeHorizontalPosition constants.public void setHorizontalAnchor(int value)
throws java.lang.Exception
RelativeHorizontalPosition.COLUMN.value - The base object from which the horizontal positioning of floating table should be calculated. The value must be one of RelativeHorizontalPosition constants.java.lang.Exceptionpublic int getVerticalAnchor()
RelativeVerticalPosition.MARGIN.RelativeVerticalPosition constants.public void setVerticalAnchor(int value)
throws java.lang.Exception
RelativeVerticalPosition.MARGIN.value - The base object from which the vertical positioning of floating table should be calculated. The value must be one of RelativeVerticalPosition constants.java.lang.Exceptionpublic double getAbsoluteHorizontalDistance()
public void setAbsoluteHorizontalDistance(double value)
throws java.lang.Exception
value - Absolute horizontal floating table position specified by the table properties, in points.java.lang.Exceptionpublic double getAbsoluteVerticalDistance()
public void setAbsoluteVerticalDistance(double value)
throws java.lang.Exception
value - Absolute vertical floating table position specified by the table properties, in points.java.lang.Exceptionpublic boolean getAllowOverlap()
true.public void setBorders(int lineStyle,
double lineWidth,
java.awt.Color color)
throws java.lang.Exception
java.lang.Exceptionpublic void setBorder(int borderType,
int lineStyle,
double lineWidth,
java.awt.Color color,
boolean isOverrideCellBorders)
throws java.lang.Exception
java.lang.Exceptionpublic void clearBorders()
public void setShading(int texture,
java.awt.Color foregroundColor,
java.awt.Color backgroundColor)
public void clearShading()
public void autoFit(int behavior)
throws java.lang.Exception
java.lang.Exception