|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.poi.POIXMLDocumentPart
org.apache.poi.xssf.usermodel.XSSFTable
public class XSSFTable
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
| 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 |
|---|
public XSSFTable()
public XSSFTable(PackagePart part)
throws java.io.IOException
part -
java.io.IOException| Method Detail |
|---|
public 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.IOException
protected 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 ID
public 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()
Table
getName in interface 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 of
columnHeaderpublic java.lang.String getSheetName()
Table
getSheetName 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()
Table
getStartColIndex in interface Tablepublic int getStartRowIndex()
Table
getStartRowIndex in interface Tablepublic int getEndColIndex()
Table
getEndColIndex in interface Tablepublic int getEndRowIndex()
Table
getEndRowIndex in interface Tablepublic TableStyleInfo getStyle()
getStyle in interface Tablepublic boolean contains(Cell cell)
Table
contains in interface TableTable.contains(org.apache.poi.ss.usermodel.Cell)protected void onTableDelete()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||