Package org.apache.poi.xwpf.usermodel
Class XWPFTableCell
- java.lang.Object
-
- org.apache.poi.xwpf.usermodel.XWPFTableCell
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
XWPFTableCell.XWPFVertAlign
-
Constructor Summary
Constructors Constructor Description XWPFTableCell(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description XWPFParagraph
addParagraph()
Add a Paragraph to this Table Cellvoid
addParagraph(XWPFParagraph p)
add a Paragraph to this TableCelljava.util.List<IBodyElement>
getBodyElements()
returns an Iterator with paragraphs and tablesjava.lang.String
getColor()
Get cell color.CTTc
getCTTc()
XWPFParagraph
getParagraph(CTP p)
Returns the paragraph corresponding to the providedCTP
.XWPFParagraph
getParagraphArray(int pos)
Returns the paragraph that of position posjava.util.List<XWPFParagraph>
getParagraphs()
returns a list of paragraphsPOIXMLDocumentPart
getPart()
get the to which the TableCell belongsBodyType
getPartType()
get the PartType of the body, for example DOCUMENT, HEADER, FOOTER, FOOTNOTE,XWPFTable
getTable(CTTbl ctTable)
get a table by its CTTbl-ObjectXWPFTable
getTableArray(int pos)
Returns the table at position posXWPFTableCell
getTableCell(CTTc cell)
get the TableCell which belongs to the TableCellXWPFTableRow
getTableRow()
java.util.List<XWPFTable>
getTables()
Return the table(s) that holds the text of the IBodyPart, for complex cases where a paragraph isn't used.java.lang.String
getText()
java.lang.String
getTextRecursively()
extracts all text recursively through embedded tables and embedded SDTsXWPFTableCell.XWPFVertAlign
getVerticalAlignment()
Get the vertical alignment of the cell.int
getWidth()
double
getWidthDecimal()
Get the table width as a decimal value.TableWidthType
getWidthType()
Get the width type for the table, as anSTTblWidth.Enum
value.XWPFDocument
getXWPFDocument()
Return XWPFDocumentXWPFParagraph
insertNewParagraph(XmlCursor cursor)
add a new paragraph at position of the cursorXWPFTable
insertNewTbl(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
removeTable(int pos)
removes a table of this table cellvoid
setColor(java.lang.String rgbStr)
Set cell color.void
setParagraph(XWPFParagraph p)
void
setText(java.lang.String text)
void
setVerticalAlignment(XWPFTableCell.XWPFVertAlign vAlign)
Set the vertical alignment of the cell.void
setWidth(java.lang.String widthValue)
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.
-
-
-
Constructor Detail
-
XWPFTableCell
public XWPFTableCell(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 Detail
-
getBodyElements
public java.util.List<IBodyElement> getBodyElements()
returns an Iterator with paragraphs and tables- Specified by:
getBodyElements
in interfaceIBody
-
setParagraph
public void setParagraph(XWPFParagraph p)
-
getParagraphs
public java.util.List<XWPFParagraph> getParagraphs()
returns a list of paragraphs- Specified by:
getParagraphs
in interfaceIBody
-
addParagraph
public XWPFParagraph addParagraph()
Add a Paragraph to this Table Cell- Returns:
- The paragraph which was added
-
addParagraph
public void addParagraph(XWPFParagraph p)
add a Paragraph to this TableCell- Parameters:
p
- the paragraph 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
public XWPFParagraph getParagraph(CTP p)
Description copied from interface:IBody
Returns the paragraph corresponding to the providedCTP
.- Specified by:
getParagraph
in interfaceIBody
- Parameters:
p
- is instance of CTP and is searching for an XWPFParagraph- Returns:
- The paragraph corresponding to the
CTP
, ornull
if there is no corresponding paragraph in this body.
-
getTableRow
public XWPFTableRow getTableRow()
-
getColor
public java.lang.String getColor()
Get cell color. Note that this method only returns the "fill" value.- Returns:
- RGB string of cell color
-
setColor
public void setColor(java.lang.String rgbStr)
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
public XWPFTableCell.XWPFVertAlign getVerticalAlignment()
Get the vertical alignment of the cell.- Returns:
- the cell alignment enum value or
null
if no vertical alignment is set.
-
setVerticalAlignment
public void setVerticalAlignment(XWPFTableCell.XWPFVertAlign vAlign)
Set the vertical alignment of the cell.- Parameters:
vAlign
- - the desired alignment enum value
-
insertNewParagraph
public XWPFParagraph insertNewParagraph(XmlCursor cursor)
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
public XWPFTable insertNewTbl(XmlCursor cursor)
Description copied from interface:IBody
inserts a new Table at the cursor position.- Specified by:
insertNewTbl
in interfaceIBody
-
getParagraphArray
public XWPFParagraph getParagraphArray(int pos)
Description copied from interface:IBody
Returns the paragraph that of position pos- Specified by:
getParagraphArray
in interfaceIBody
-
getPart
public POIXMLDocumentPart getPart()
get the to which the TableCell belongs
-
getPartType
public BodyType 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
-
getTableArray
public XWPFTable getTableArray(int pos)
Description copied from interface:IBody
Returns the table at position pos- Specified by:
getTableArray
in interfaceIBody
-
getTables
public java.util.List<XWPFTable> 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
public void insertTable(int pos, XWPFTable table)
inserts an existing XWPFTable to the arrays bodyElements and tables- Specified by:
insertTable
in interfaceIBody
-
removeTable
public void removeTable(int pos)
removes a table of this table cell- Parameters:
pos
- The position in the list of tables, 0-based
-
getText
public java.lang.String getText()
-
setText
public void setText(java.lang.String text)
-
getTextRecursively
public java.lang.String getTextRecursively()
extracts all text recursively through embedded tables and embedded SDTs
-
getTableCell
public XWPFTableCell getTableCell(CTTc cell)
get the TableCell which belongs to the TableCell- Specified by:
getTableCell
in interfaceIBody
-
getXWPFDocument
public XWPFDocument 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
public TableWidthType 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
public void setWidth(java.lang.String widthValue)
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
-
setWidthType
public void setWidthType(TableWidthType widthType)
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()
-
-