Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.poi.xssf.usermodel
Class XSSFTable

    java.lang.Object
      org.apache.poi.POIXMLDocumentPart
          org.apache.poi.xssf.usermodel.XSSFTable

All Implemented Interfaces:
  Table

    public class XSSFTable

extends POIXMLDocumentPart
implements Table

This class implements the Table Part (Open Office XML Part 4: chapter 3.5.1) This implementation works under the assumption that a table contains mappings to a subtree of an XML. The root element of this subtree an occur multiple times (one for each row of the table). The child nodes of the root element can be only attributes or element with maxOccurs=1 property set

Author:
  Roberto Manicardi

Nested Class Summary

Nested classes/interfaces inherited from class org.apache.poi.POIXMLDocumentPart
`POIXMLDocumentPart.RelationPart`

Field Summary

Fields inherited from interface org.apache.poi.ss.usermodel.Table
`isStructuredReference`

Constructor Summary
`XSSFTable()` empty implementation, not attached to a workbook/worksheet yet
`XSSFTable(PackagePart part)`

Method Summary
`void` | `addColumn()` Adds another column to the table.
`protected void` | `commit()` Save the content in the underlying package part.
`boolean` | `contains(Cell cell)` checks if the given cell is part of the table.
`int` | `findColumnIndex(java.lang.String columnHeader)` Gets the relative column index of a column in this table having the header name `column`.
`AreaReference` | `getCellReferences()`
`java.lang.String` | `getCommonXpath()` Calculates the xpath of the root element for the table.
`org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTable` | `getCTTable()` get the underlying CTTable XML bean
`java.lang.String` | `getDisplayName()`
`CellReference` | `getEndCellReference()`
`int` | `getEndColIndex()` Get the bottom-right column index on the sheet
`int` | `getEndRowIndex()` Get the bottom-right row index
`int` | `getHeaderRowCount()`
`java.lang.String` | `getName()` Get the name of the table.
`long` | `getNumberOfMappedColumns()`
`long` | `getNumerOfMappedColumns()` Deprecated. 3.15 beta 2. Use `getNumberOfMappedColumns()`.
`int` | `getRowCount()`
`java.lang.String` | `getSheetName()` Returns the sheet name that the table belongs to.
`CellReference` | `getStartCellReference()`
`int` | `getStartColIndex()` Get the top-left column index relative to the sheet
`int` | `getStartRowIndex()` Get the top-left row index on the sheet
`TableStyleInfo` | `getStyle()`
`java.lang.String` | `getStyleName()`
`int` | `getTotalsRowCount()`
`java.util.List<XSSFXmlColumnPr>` | `getXmlColumnPrs()` Note this list is static - once read, it does not notice later changes to the underlying column structures To clear the cache, call `updateHeaders()`
`XSSFSheet` | `getXSSFSheet()`
`boolean` | `isHasTotalsRow()` Note: This is misleading.
`boolean` | `mapsTo(long id)` Checks if this Table element contains even a single mapping to the map identified by id
`protected void` | `onTableDelete()` Remove relations
`void` | `readFrom(java.io.InputStream is)` read table XML
`void` | `setCellReferences(AreaReference refs)` Updates the reference for the cells of the table (see Open Office XML Part 4: chapter 3.5.1.2, attribute ref) and synchronizes any changes
`void` | `setDisplayName(java.lang.String name)` Changes the display name of the Table
`void` | `setName(java.lang.String newName)` Changes the name of the Table
`void` | `setStyleName(java.lang.String newStyleName)` Changes the name of the Table
`void` | `updateHeaders()` Synchronize table headers with cell values in the parent sheet.
`void` | `updateReferences()` Clears the cached values set by `getStartCellReference()` and `getEndCellReference()`.
`void` | `writeTo(java.io.OutputStream out)` write table XML to stream

Methods inherited from class org.apache.poi.POIXMLDocumentPart
`_invokeOnDocumentRead, addRelation, createRelationship, createRelationship, createRelationship, getNextPartNumber, getPackagePart, getParent, getRelationById, getRelationId, getRelationParts, getRelations, getTargetPart, onDocumentCreate, onDocumentRead, onDocumentRemove, onSave, prepareForCommit, read, rebase, removeRelation, removeRelation, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### XSSFTable

    public XSSFTable()

  empty implementation, not attached to a workbook/worksheet yet

### XSSFTable

    public XSSFTable(PackagePart part)
              throws java.io.IOException

Parameters:
  `part` -
Throws:
  `java.io.IOException`
Since:
  POI 3.14-Beta1

Method Detail

### readFrom

    public void readFrom(java.io.InputStream is)
                  throws java.io.IOException

  read table XML

  Parameters:
    `is` -
  Throws:
    `java.io.IOException`

### getXSSFSheet

    public XSSFSheet getXSSFSheet()

  Returns:
    owning sheet

### writeTo

    public void writeTo(java.io.OutputStream out)
                 throws java.io.IOException

  write table XML to stream

  Parameters:
    `out` -
  Throws:
    `java.io.IOException`

### commit

    protected void commit()
                   throws java.io.IOException

  Description copied from class: `POIXMLDocumentPart`
  Save the content in the underlying package part. Default implementation is empty meaning that the package part is left unmodified. Sub-classes should override and add logic to marshal the "model" into Ooxml4J. For example, the code saving a generic XML entry may look as follows:

       protected void commit() throws IOException {
         PackagePart part = getPackagePart();
         OutputStream out = part.getOutputStream();
         XmlObject bean = getXmlBean(); //the "model" which holds changes in memory
         bean.save(out, DEFAULT_XML_OPTIONS);
         out.close();
       }

  Overrides:
    `commit` in class `POIXMLDocumentPart`
  Throws:
    `java.io.IOException` - a subclass may throw an IOException if the changes can't be committed

### getCTTable

    @Internal(since="POI 3.15 beta 3")
    public org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTable getCTTable()

  get the underlying CTTable XML bean

  Returns:
    underlying OOXML object

### mapsTo

    public boolean mapsTo(long id)

  Checks if this Table element contains even a single mapping to the map identified by id

  Parameters:
    `id` - the XSSFMap ID
  Returns:
    true if the Table element contain mappings

### getCommonXpath

    public java.lang.String getCommonXpath()

  Calculates the xpath of the root element for the table. This will be the common part of all the mapping's xpaths Note: this function caches the result for performance. To flush the cache `updateHeaders()` must be called.

  Returns:
    the xpath of the table's root element

### getXmlColumnPrs

    public java.util.List<XSSFXmlColumnPr> getXmlColumnPrs()

  Note this list is static - once read, it does not notice later changes to the underlying column structures To clear the cache, call `updateHeaders()`

  Returns:
    List of XSSFXmlColumnPr

### addColumn

    @Internal(value="Return type likely to change")
    public void addColumn()

  Adds another column to the table. Warning - Return type likely to change!

### getName

    public java.lang.String getName()

  Description copied from interface: `Table`
  Get the name of the table.

  Specified by:
    `getName` in interface `Table`
  Returns:
    the name of the Table, if set

### setName

    public void setName(java.lang.String newName)

  Changes the name of the Table

  Parameters:
    `newName` -

### getStyleName

    public java.lang.String getStyleName()

  Specified by:
    `getStyleName` in interface `Table`
  Returns:
    the table style name, if set
  Since:
    3.17 beta 1

### setStyleName

    public void setStyleName(java.lang.String newStyleName)

  Changes the name of the Table

  Parameters:
    `newStyleName` -
  Since:
    3.17 beta 1

### getDisplayName

    public java.lang.String getDisplayName()

  Returns:
    the display name of the Table, if set

### setDisplayName

    public void setDisplayName(java.lang.String name)

  Changes the display name of the Table

  Parameters:
    `name` - to use

### getNumberOfMappedColumns

    public long getNumberOfMappedColumns()

  Returns:
    the number of mapped table columns (see Open Office XML Part 4: chapter 3.5.1.4)

### getNumerOfMappedColumns

    public long getNumerOfMappedColumns()

  Deprecated. 3.15 beta 2. Use `getNumberOfMappedColumns()`.

  Returns:
    the number of mapped table columns (see Open Office XML Part 4: chapter 3.5.1.4)

### getCellReferences

    public AreaReference getCellReferences()

  Returns:
    The reference for the cells of the table (see Open Office XML Part 4: chapter 3.5.1.2, attribute ref) Does not track updates to underlying changes to CTTable To synchronize with changes to the underlying CTTable, call `updateReferences()`.
  Since:
    3.17 beta 1

### setCellReferences

    public void setCellReferences(AreaReference refs)

  Updates the reference for the cells of the table (see Open Office XML Part 4: chapter 3.5.1.2, attribute ref) and synchronizes any changes

  Since:
    3.17 beta 1

### getStartCellReference

    public CellReference getStartCellReference()

  Returns:
    The reference for the cell in the top-left part of the table (see Open Office XML Part 4: chapter 3.5.1.2, attribute ref) Does not track updates to underlying changes to CTTable To synchronize with changes to the underlying CTTable, call `updateReferences()`.

### getEndCellReference

    public CellReference getEndCellReference()

  Returns:
    The reference for the cell in the bottom-right part of the table (see Open Office XML Part 4: chapter 3.5.1.2, attribute ref) Does not track updates to underlying changes to CTTable To synchronize with changes to the underlying CTTable, call `updateReferences()`.

### updateReferences

    public void updateReferences()

  Clears the cached values set by `getStartCellReference()` and `getEndCellReference()`. The next call to `getStartCellReference()` and `getEndCellReference()` will synchronize the cell references with the underlying `CTTable`. Thus, `updateReferences()` is inexpensive.

  Since:
    POI 3.15 beta 3

### getRowCount

    public int getRowCount()

  Returns:
    the total number of rows in the selection. (Note: in this version autofiltering is ignored) Returns `0` if the start or end cell references are not set. Does not track updates to underlying changes to CTTable To synchronize with changes to the underlying CTTable, call `updateReferences()`.

### updateHeaders

    public void updateHeaders()

  Synchronize table headers with cell values in the parent sheet. Headers must be in sync, otherwise Excel will display a "Found unreadable content" message on startup. If calling both `updateReferences()` and `updateHeaders()`, `updateReferences()` should be called first. Note that a Table must have a header. To reproduce the equivalent of inserting a table in Excel without Headers, manually add cells with values of "Column1", "Column2" etc first.

### findColumnIndex

    public int findColumnIndex(java.lang.String columnHeader)

  Gets the relative column index of a column in this table having the header name `column`. The column index is relative to the left-most column in the table, 0-indexed. Returns `-1` if `column` is not a header name in table. Column Header names are case-insensitive Note: this function caches column names for performance. To flush the cache (because columns have been moved or column headers have been changed), `updateHeaders()` must be called.

  Specified by:
    `findColumnIndex` in interface `Table`
  Parameters:
    `columnHeader` - the column header name to get the table column index of
  Returns:
    column index corresponding to `columnHeader`
  Since:
    3.15 beta 2

### getSheetName

    public java.lang.String getSheetName()

  Description copied from interface: `Table`
  Returns the sheet name that the table belongs to.

  Specified by:
    `getSheetName` in interface `Table`
  Returns:
    sheet name
  Since:
    3.15 beta 2

### isHasTotalsRow

    public boolean isHasTotalsRow()

  Note: This is misleading. The Spec indicates this is true if the totals row has ever been shown, not whether or not it is currently displayed. Use `getTotalsRowCount()` > 0 to decide whether or not the totals row is visible.

  Specified by:
    `isHasTotalsRow` in interface `Table`
  Returns:
    true if a totals row has ever been shown for this table
  Since:
    3.15 beta 2
  See Also:
    `getTotalsRowCount()`

### getTotalsRowCount

    public int getTotalsRowCount()

  Specified by:
    `getTotalsRowCount` in interface `Table`
  Returns:
    0 for no totals rows, 1 for totals row shown. Values > 1 are not currently used by Excel up through 2016, and the OOXML spec doesn't define how they would be implemented.
  Since:
    3.17 beta 1

### getHeaderRowCount

    public int getHeaderRowCount()

  Specified by:
    `getHeaderRowCount` in interface `Table`
  Returns:
    0 for no header rows, 1 for table headers shown. Values > 1 might be used by Excel for pivot tables?
  Since:
    3.17 beta 1

### getStartColIndex

    public int getStartColIndex()

  Description copied from interface: `Table`
  Get the top-left column index relative to the sheet

  Specified by:
    `getStartColIndex` in interface `Table`
  Returns:
    table start column index on sheet
  Since:
    3.15 beta 2

### getStartRowIndex

    public int getStartRowIndex()

  Description copied from interface: `Table`
  Get the top-left row index on the sheet

  Specified by:
    `getStartRowIndex` in interface `Table`
  Returns:
    table start row index on sheet
  Since:
    3.15 beta 2

### getEndColIndex

    public int getEndColIndex()

  Description copied from interface: `Table`
  Get the bottom-right column index on the sheet

  Specified by:
    `getEndColIndex` in interface `Table`
  Returns:
    table end column index on sheet
  Since:
    3.15 beta 2

### getEndRowIndex

    public int getEndRowIndex()

  Description copied from interface: `Table`
  Get the bottom-right row index

  Specified by:
    `getEndRowIndex` in interface `Table`
  Returns:
    table end row index on sheet
  Since:
    3.15 beta 2

### getStyle

    public TableStyleInfo getStyle()

  Specified by:
    `getStyle` in interface `Table`
  Returns:
    TableStyleInfo for this instance
  Since:
    3.17 beta 1

### contains

    public boolean contains(Cell cell)

  Description copied from interface: `Table`
  checks if the given cell is part of the table. Includes checking that they are on the same sheet.

  Specified by:
    `contains` in interface `Table`
  Returns:
    true if the table and cell are on the same sheet and the cell is within the table range.
  Since:
    3.17 beta 1
  See Also:
    `Table.contains(org.apache.poi.ss.usermodel.Cell)`

### onTableDelete

    protected void onTableDelete()

  Remove relations

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 2017 The Apache Software Foundation or its licensors, as applicable.