public class XSSFTable extends POIXMLDocumentPart implements Table
POIXMLDocumentPart.RelationPartisStructuredReference| Constructor and Description |
|---|
XSSFTable()
empty implementation, not attached to a workbook/worksheet yet
|
XSSFTable(PackagePart part) |
| Modifier and Type | Method and Description |
|---|---|
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
|
_invokeOnDocumentRead, addRelation, createRelationship, createRelationship, createRelationship, getNextPartNumber, getPackagePart, getParent, getRelationById, getRelationId, getRelationParts, getRelations, getTargetPart, onDocumentCreate, onDocumentRead, onDocumentRemove, onSave, prepareForCommit, read, rebase, removeRelation, removeRelation, toStringpublic XSSFTable()
public XSSFTable(PackagePart part) throws java.io.IOException
part - java.io.IOExceptionpublic void readFrom(java.io.InputStream is)
throws java.io.IOException
is - java.io.IOExceptionpublic XSSFSheet getXSSFSheet()
public void writeTo(java.io.OutputStream out)
throws java.io.IOException
out - java.io.IOExceptionprotected void commit()
throws java.io.IOException
POIXMLDocumentPart
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();
}
commit in class POIXMLDocumentPartjava.io.IOException - a subclass may throw an IOException if the changes can't be committed@Internal(since="POI 3.15 beta 3") public org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTable getCTTable()
public boolean mapsTo(long id)
id - the XSSFMap IDpublic java.lang.String getCommonXpath()
updateHeaders() must be called.public java.util.List<XSSFXmlColumnPr> getXmlColumnPrs()
updateHeaders()@Internal(value="Return type likely to change") public void addColumn()
public java.lang.String getName()
Tablepublic void setName(java.lang.String newName)
newName - public java.lang.String getStyleName()
getStyleName in interface Tablepublic void setStyleName(java.lang.String newStyleName)
newStyleName - public java.lang.String getDisplayName()
public void setDisplayName(java.lang.String name)
name - to usepublic long getNumberOfMappedColumns()
public long getNumerOfMappedColumns()
getNumberOfMappedColumns().public AreaReference getCellReferences()
updateReferences().public void setCellReferences(AreaReference refs)
public CellReference getStartCellReference()
updateReferences().public CellReference getEndCellReference()
updateReferences().public void updateReferences()
getStartCellReference()
and getEndCellReference().
The next call to getStartCellReference() and
getEndCellReference() will synchronize the
cell references with the underlying CTTable.
Thus, updateReferences() is inexpensive.public int getRowCount()
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().public void updateHeaders()
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.public int findColumnIndex(java.lang.String columnHeader)
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.findColumnIndex in interface TablecolumnHeader - the column header name to get the table column index ofcolumnHeaderpublic java.lang.String getSheetName()
TablegetSheetName in interface Tablepublic boolean isHasTotalsRow()
getTotalsRowCount() > 0 to decide whether or not the totals row is visible.isHasTotalsRow in interface TablegetTotalsRowCount()public int getTotalsRowCount()
getTotalsRowCount in interface Tablepublic int getHeaderRowCount()
getHeaderRowCount in interface Tablepublic int getStartColIndex()
TablegetStartColIndex in interface Tablepublic int getStartRowIndex()
TablegetStartRowIndex in interface Tablepublic int getEndColIndex()
TablegetEndColIndex in interface Tablepublic int getEndRowIndex()
TablegetEndRowIndex in interface Tablepublic TableStyleInfo getStyle()
public boolean contains(Cell cell)
Tablecontains in interface TableTable.contains(org.apache.poi.ss.usermodel.Cell)protected void onTableDelete()
Copyright 2018 The Apache Software Foundation or its licensors, as applicable.