org.apache.poi.xwpf.usermodel
Class XWPFTable
- java.lang.Object
-
- org.apache.poi.xwpf.usermodel.XWPFTable
-
- All Implemented Interfaces:
- IBodyElement, ISDTContents
public class XWPFTable extends java.lang.Object implements IBodyElement, ISDTContents
Sketch of XWPFTable class. Only table's text is being hold.
Specifies the contents of a table present in the document. A table is a set of paragraphs (and other block-level content) arranged in rows and columns.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classXWPFTable.XWPFBorderType
-
Constructor Summary
Constructors Constructor and Description XWPFTable(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl table, IBody part)XWPFTable(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl table, IBody part, int row, int col)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddNewCol()add a new column for each row in this tablevoidaddNewRowBetween(int start, int end)voidaddRow(XWPFTableRow row)add a new Row to the tablebooleanaddRow(XWPFTableRow row, int pos)add a new Row to the table at position posXWPFTableRowcreateRow()create a new XWPFTableRow object with as many cells as the number of columns defined in that momentIBodygetBody()intgetCellMarginBottom()intgetCellMarginLeft()intgetCellMarginRight()intgetCellMarginTop()intgetColBandSize()org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblgetCTTbl()BodyElementTypegetElementType()returns the type of the BodyElement Tablejava.lang.StringgetInsideHBorderColor()intgetInsideHBorderSize()intgetInsideHBorderSpace()XWPFTable.XWPFBorderTypegetInsideHBorderType()java.lang.StringgetInsideVBorderColor()intgetInsideVBorderSize()intgetInsideVBorderSpace()XWPFTable.XWPFBorderTypegetInsideVBorderType()intgetNumberOfRows()POIXMLDocumentPartgetPart()returns the part of the bodyElementBodyTypegetPartType()returns the partType of the bodyPart which owns the bodyElementXWPFTableRowgetRow(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRow row)returns the XWPFRow which belongs to the CTRow row if this row is not existing in the table null will be returnedXWPFTableRowgetRow(int pos)intgetRowBandSize()java.util.List<XWPFTableRow>getRows()java.lang.StringgetStyleID()get the StyleID of the tablejava.lang.StringgetText()Convenience method to extract text in cells.intgetWidth()XWPFTableRowinsertNewTableRow(int pos)inserts a new tablerowbooleanremoveRow(int pos)Remove a row at position pos from the tablevoidsetCellMargins(int top, int left, int bottom, int right)voidsetColBandSize(int size)voidsetInsideHBorder(XWPFTable.XWPFBorderType type, int size, int space, java.lang.String rgbColor)voidsetInsideVBorder(XWPFTable.XWPFBorderType type, int size, int space, java.lang.String rgbColor)voidsetRowBandSize(int size)voidsetStyleID(java.lang.String styleName)Set the table style.voidsetWidth(int width)
-
-
-
Constructor Detail
-
XWPFTable
public XWPFTable(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl table, IBody part, int row, int col)
-
XWPFTable
public XWPFTable(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl table, IBody part)
-
-
Method Detail
-
getCTTbl
@Internal public org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl getCTTbl()
- Returns:
- ctTbl object
-
getText
public java.lang.String getText()
Convenience method to extract text in cells. This does not extract text recursively in cells, and it does not currently include text in SDT (form) components.To get all text within a table, see XWPFWordExtractor's appendTableText as an example.
- Returns:
- text
-
addNewRowBetween
public void addNewRowBetween(int start, int end)
-
addNewCol
public void addNewCol()
add a new column for each row in this table
-
createRow
public XWPFTableRow createRow()
create a new XWPFTableRow object with as many cells as the number of columns defined in that moment- Returns:
- tableRow
-
getRow
public XWPFTableRow getRow(int pos)
- Parameters:
pos- - index of the row- Returns:
- the row at the position specified or null if no rows is defined or if the position is greather than the max size of rows array
-
setWidth
public void setWidth(int width)
- Parameters:
width-
-
getWidth
public int getWidth()
- Returns:
- width value
-
getNumberOfRows
public int getNumberOfRows()
- Returns:
- number of rows in table
-
getStyleID
public java.lang.String getStyleID()
get the StyleID of the table- Returns:
- style-ID of the table
-
setStyleID
public void setStyleID(java.lang.String styleName)
Set the table style. If the style is not defined in the document, MS Word will set the table style to "Normal".- Parameters:
styleName- - the style name to apply to this table
-
getInsideHBorderType
public XWPFTable.XWPFBorderType getInsideHBorderType()
-
getInsideHBorderSize
public int getInsideHBorderSize()
-
getInsideHBorderSpace
public int getInsideHBorderSpace()
-
getInsideHBorderColor
public java.lang.String getInsideHBorderColor()
-
getInsideVBorderType
public XWPFTable.XWPFBorderType getInsideVBorderType()
-
getInsideVBorderSize
public int getInsideVBorderSize()
-
getInsideVBorderSpace
public int getInsideVBorderSpace()
-
getInsideVBorderColor
public java.lang.String getInsideVBorderColor()
-
getRowBandSize
public int getRowBandSize()
-
setRowBandSize
public void setRowBandSize(int size)
-
getColBandSize
public int getColBandSize()
-
setColBandSize
public void setColBandSize(int size)
-
setInsideHBorder
public void setInsideHBorder(XWPFTable.XWPFBorderType type, int size, int space, java.lang.String rgbColor)
-
setInsideVBorder
public void setInsideVBorder(XWPFTable.XWPFBorderType type, int size, int space, java.lang.String rgbColor)
-
getCellMarginTop
public int getCellMarginTop()
-
getCellMarginLeft
public int getCellMarginLeft()
-
getCellMarginBottom
public int getCellMarginBottom()
-
getCellMarginRight
public int getCellMarginRight()
-
setCellMargins
public void setCellMargins(int top, int left, int bottom, int right)
-
addRow
public void addRow(XWPFTableRow row)
add a new Row to the table- Parameters:
row- the row which should be added
-
addRow
public boolean addRow(XWPFTableRow row, int pos)
add a new Row to the table at position pos- Parameters:
row- the row which should be added
-
insertNewTableRow
public XWPFTableRow insertNewTableRow(int pos)
inserts a new tablerow- Parameters:
pos-- Returns:
- the inserted row
-
removeRow
public boolean removeRow(int pos) throws java.lang.IndexOutOfBoundsExceptionRemove a row at position pos from the table- Parameters:
pos- position the Row in the Table- Throws:
java.lang.IndexOutOfBoundsException
-
getRows
public java.util.List<XWPFTableRow> getRows()
-
getElementType
public BodyElementType getElementType()
returns the type of the BodyElement Table- Specified by:
getElementTypein interfaceIBodyElement- See Also:
IBodyElement.getElementType()
-
getBody
public IBody getBody()
- Specified by:
getBodyin interfaceIBodyElement
-
getPart
public POIXMLDocumentPart getPart()
returns the part of the bodyElement- Specified by:
getPartin interfaceIBodyElement- See Also:
IBody.getPart()
-
getPartType
public BodyType getPartType()
returns the partType of the bodyPart which owns the bodyElement- Specified by:
getPartTypein interfaceIBodyElement- See Also:
IBody.getPartType()
-
getRow
public XWPFTableRow getRow(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRow row)
returns the XWPFRow which belongs to the CTRow row if this row is not existing in the table null will be returned
-
-
DataMelt 3.0 © DataMelt by jWork.ORG