Package org.apache.poi.xwpf.usermodel
Class XWPFTableCell
java.lang.Object
org.apache.poi.xwpf.usermodel.XWPFTableCell
Represents a Cell within a
XWPFTable
. The
Cell is the thing that holds the actual content (paragraphs etc)-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<IBodyElement>
protected List<XWPFParagraph>
protected IBody
-
Constructor Summary
ConstructorsConstructorDescriptionXWPFTableCell
(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc cell, XWPFTableRow tableRow, IBody part) If a table cell does not include at least one block-level element, then this document shall be considered corrupt -
Method Summary
Modifier and TypeMethodDescriptionAdd a Paragraph to this Table Cellvoid
add a Paragraph to this TableCellreturns an Iterator with paragraphs and tablesgetColor()
Get cell color.org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc
getCTTc()
getParagraph
(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP p) if there is a correspondingXWPFParagraph
of the parameter ctTable in the paragraphList of this table the method will return this paragraph if there is no correspondingXWPFParagraph
the method will return nullgetParagraphArray
(int pos) Returns the paragraph that of position posreturns a list of paragraphsgetPart()
get the to which the TableCell belongsget the PartType of the body, for example DOCUMENT, HEADER, FOOTER, FOOTNOTE,getTable
(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl ctTable) get a table by its CTTbl-ObjectgetTableArray
(int pos) Returns the table at position posgetTableCell
(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc cell) get the TableCell which belongs to the TableCellReturn the table(s) that holds the text of the IBodyPart, for complex cases where a paragraph isn't used.protected org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTcPr
getTcPr()
Get the cell properties for the cell.getText()
extracts all text recursively through embedded tables and embedded SDTsGet the vertical alignment of the cell.int
getWidth()
double
Get the table width as a decimal value.Get the width type for the table, as anSTTblWidth.Enum
value.Return XWPFDocumentinsertNewParagraph
(org.apache.xmlbeans.XmlCursor cursor) add a new paragraph at position of the cursorinsertNewTbl
(org.apache.xmlbeans.XmlCursor cursor) inserts a new Table at the cursor position.void
insertTable
(int pos, XWPFTable table) inserts an existing XWPFTable to the arrays bodyElements and tablesvoid
removeParagraph
(int pos) removes a paragraph of this tablecellvoid
Set cell color.void
void
void
Set the vertical alignment of the cell.void
Set the width to the value "auto", an integer value (20ths of a point), or a percentage ("nn.nn%").void
setWidthType
(TableWidthType widthType) Set the width value type for the table.
-
Field Details
-
paragraphs
-
tables
-
bodyElements
-
part
-
-
Constructor Details
-
XWPFTableCell
public XWPFTableCell(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc cell, XWPFTableRow tableRow, IBody part) If a table cell does not include at least one block-level element, then this document shall be considered corrupt
-
-
Method Details
-
getCTTc
-
getBodyElements
returns an Iterator with paragraphs and tables- Specified by:
getBodyElements
in interfaceIBody
- See Also:
-
setParagraph
-
getParagraphs
returns a list of paragraphs- Specified by:
getParagraphs
in interfaceIBody
-
addParagraph
Add a Paragraph to this Table Cell- Returns:
- The paragraph which was added
-
addParagraph
add a Paragraph to this TableCell- Parameters:
p
- the paragaph which has to be added
-
removeParagraph
public void removeParagraph(int pos) removes a paragraph of this tablecell- Parameters:
pos
- The position in the list of paragraphs, 0-based
-
getParagraph
if there is a correspondingXWPFParagraph
of the parameter ctTable in the paragraphList of this table the method will return this paragraph if there is no correspondingXWPFParagraph
the method will return null- Specified by:
getParagraph
in interfaceIBody
- Parameters:
p
- is instance of CTP and is searching for an XWPFParagraph- Returns:
- null if there is no XWPFParagraph with an corresponding CTPparagraph in the paragraphList of this table XWPFParagraph with the correspondig CTP p
-
getTableRow
-
getColor
Get cell color. Note that this method only returns the "fill" value.- Returns:
- RGB string of cell color
-
setColor
Set cell color. This sets some associated values; for finer control you may want to access these elements individually.- Parameters:
rgbStr
- - the desired cell color, in the hex form "RRGGBB".
-
getVerticalAlignment
Get the vertical alignment of the cell.- Returns:
- the cell alignment enum value or
null
if no vertical alignment is set.
-
setVerticalAlignment
Set the vertical alignment of the cell.- Parameters:
vAlign
- - the desired alignment enum value
-
insertNewParagraph
add a new paragraph at position of the cursor- Specified by:
insertNewParagraph
in interfaceIBody
- Parameters:
cursor
- The XmlCursor structure created with XmlBeans- Returns:
- the inserted paragraph
-
insertNewTbl
Description copied from interface:IBody
inserts a new Table at the cursor position.- Specified by:
insertNewTbl
in interfaceIBody
-
getParagraphArray
Description copied from interface:IBody
Returns the paragraph that of position pos- Specified by:
getParagraphArray
in interfaceIBody
- See Also:
-
getPart
get the to which the TableCell belongs -
getPartType
Description copied from interface:IBody
get the PartType of the body, for example DOCUMENT, HEADER, FOOTER, FOOTNOTE,- Specified by:
getPartType
in interfaceIBody
- Returns:
- the PartType of the body
- See Also:
-
getTable
get a table by its CTTbl-Object -
getTableArray
Description copied from interface:IBody
Returns the table at position pos- Specified by:
getTableArray
in interfaceIBody
- See Also:
-
getTables
Description copied from interface:IBody
Return the table(s) that holds the text of the IBodyPart, for complex cases where a paragraph isn't used. -
insertTable
inserts an existing XWPFTable to the arrays bodyElements and tables- Specified by:
insertTable
in interfaceIBody
- See Also:
-
getText
-
setText
-
getTextRecursively
extracts all text recursively through embedded tables and embedded SDTs -
getTableCell
get the TableCell which belongs to the TableCell- Specified by:
getTableCell
in interfaceIBody
-
getXWPFDocument
Description copied from interface:IBody
Return XWPFDocument- Specified by:
getXWPFDocument
in interfaceIBody
-
getWidthDecimal
public double getWidthDecimal()Get the table width as a decimal value.If the width type is DXA or AUTO, then the value will always have a fractional part of zero (because these values are really integers). If the with type is percentage, then value may have a non-zero fractional part.
- Returns:
- Width value as a double-precision decimal.
- Since:
- 4.0.0
-
getWidthType
Get the width type for the table, as anSTTblWidth.Enum
value. A table width can be specified as an absolute measurement (an integer number of twips), a percentage, or the value "AUTO".- Returns:
- The width type.
- Since:
- 4.0.0
-
setWidth
Set the width to the value "auto", an integer value (20ths of a point), or a percentage ("nn.nn%").- Parameters:
widthValue
- String matching one of "auto", [0-9]+, or [0-9]+(\.[0-9]+)%.- Since:
- 4.0.0
-
getTcPr
protected org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTcPr getTcPr()Get the cell properties for the cell.- Returns:
- The cell properties
- Since:
- 4.0.0
-
setWidthType
Set the width value type for the table.If the width type is changed from the current type and the currently-set value is not consistent with the new width type, the value is reset to the default value for the specified width type.
- Parameters:
widthType
- Width type- Since:
- 4.0.0
-
getWidth
public int getWidth()
-