Class XWPFTableCell

  • All Implemented Interfaces:
    IBody, ICell

    public class XWPFTableCell
    extends Object
    implements IBody, ICell
    Represents a Cell within a XWPFTable. The Cell is the thing that holds the actual content (paragraphs etc)
    • 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

      • addParagraph

        public XWPFParagraph addParagraph()
        Add a Paragraph to this Table Cell
        The paragraph which was added
      • addParagraph

        public void addParagraph​(XWPFParagraph p)
        add a Paragraph to this TableCell
        p - the paragaph which has to be added
      • removeParagraph

        public void removeParagraph​(int pos)
        removes a paragraph of this tablecell
        pos - The position in the list of paragraphs, 0-based
      • getParagraph

        public XWPFParagraph getParagraph​(CTP p)
        if there is a corresponding XWPFParagraph of the parameter ctTable in the paragraphList of this table the method will return this paragraph if there is no corresponding XWPFParagraph the method will return null
        Specified by:
        getParagraph in interface IBody
        p - is instance of CTP and is searching for an XWPFParagraph
        null if there is no XWPFParagraph with an corresponding CTPparagraph in the paragraphList of this table XWPFParagraph with the correspondig CTP p
      • getColor

        public String getColor()
        Get cell color. Note that this method only returns the "fill" value.
        RGB string of cell color
      • setColor

        public void setColor​(String rgbStr)
        Set cell color. This sets some associated values; for finer control you may want to access these elements individually.
        rgbStr - - the desired cell color, in the hex form "RRGGBB".
      • getVerticalAlignment

        public XWPFTableCell.XWPFVertAlign getVerticalAlignment()
        Get the vertical alignment of the cell.
        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.
        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 interface IBody
        cursor - The XmlCursor structure created with XmlBeans
        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 interface IBody
      • 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 interface IBody
        the PartType of the body
        See Also:
      • getTables

        public 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.
        Specified by:
        getTables in interface IBody
        See Also:
      • getText

        public String getText()
      • setText

        public void setText​(String text)
      • getTextRecursively

        public String getTextRecursively()
        extracts all text recursively through embedded tables and embedded SDTs
      • 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.

        Width value as a double-precision decimal.
      • getWidthType

        public TableWidthType getWidthType()
        Get the width type for the table, as an STTblWidth.Enum value. A table width can be specified as an absolute measurement (an integer number of twips), a percentage, or the value "AUTO".
        The width type.
      • setWidth

        public void setWidth​(String widthValue)
        Set the width to the value "auto", an integer value (20ths of a point), or a percentage ("nn.nn%").
        widthValue - String matching one of "auto", [0-9]+, or [0-9]+(\.[0-9]+)%.
      • 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.

        widthType - Width type
      • getWidth

        public int getWidth()