Class XSLFTable

    • Method Detail

      • getCell

        public XSLFTableCell getCell​(int row,
                                     int col)
        Description copied from interface: TableShape
        Gets a cell
        Specified by:
        getCell in interface TableShape<XSLFShape,​XSLFTextParagraph>
        Parameters:
        row - the row index (0-based)
        col - the column index (0-based)
        Returns:
        the cell or null if the cell doesn't exists, e.g. when accessing a merged cell or if the index is out of bounds
      • getNumberOfColumns

        public int getNumberOfColumns()
        Description copied from interface: TableShape
        Return the maximum number of columns. If the table contains merged cells, the number of columns might be less than the maximum.
        Specified by:
        getNumberOfColumns in interface TableShape<XSLFShape,​XSLFTextParagraph>
        Returns:
        the maximum number of column
      • getColumnWidth

        public double getColumnWidth​(int idx)
        Description copied from interface: TableShape
        Gets the width (in points) of the n-th column
        Specified by:
        getColumnWidth in interface TableShape<XSLFShape,​XSLFTextParagraph>
        Parameters:
        idx - the column index (0-based)
        Returns:
        the width (in points)
      • setColumnWidth

        public void setColumnWidth​(int idx,
                                   double width)
        Description copied from interface: TableShape
        Sets the width (in points) of the n-th column
        Specified by:
        setColumnWidth in interface TableShape<XSLFShape,​XSLFTextParagraph>
        Parameters:
        idx - the column index (0-based)
        width - the width (in points)
      • setRowHeight

        public void setRowHeight​(int row,
                                 double height)
        Description copied from interface: TableShape
        Sets the row height.
        Specified by:
        setRowHeight in interface TableShape<XSLFShape,​XSLFTextParagraph>
        Parameters:
        row - the row index (0-based)
        height - the height to set (in points)
      • iterator

        public java.util.Iterator<XSLFTableRow> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<XSLFTableRow>
      • insertRow

        public XSLFTableRow insertRow​(int rowIdx)
        Insert a new row at the given index.
        Parameters:
        rowIdx - the row index.
        Since:
        POI 5.0.0
      • removeRow

        public void removeRow​(int rowIdx)
        Remove the row on the given index
        Parameters:
        rowIdx - the row index
      • addColumn

        public void addColumn()
        Add a new column at the end of the table.
        Since:
        POI 4.1.2
      • insertColumn

        public void insertColumn​(int colIdx)
        Insert a new column at the given index.
        Parameters:
        colIdx - the column index.
        Since:
        POI 4.1.2
      • removeColumn

        public void removeColumn​(int colIdx)
        Remove the column at the given index.
        Parameters:
        colIdx - the column index.
        Since:
        POI 4.1.2
      • mergeCells

        public void mergeCells​(int firstRow,
                               int lastRow,
                               int firstCol,
                               int lastCol)
        Merge cells of a table
      • updateCellAnchor

        public void updateCellAnchor()
        Calculates the bounding boxes of all cells and updates the dimension of the table