public class XSSFPivotTable extends POIXMLDocumentPart
Modifier and Type | Class and Description |
---|---|
protected static interface |
XSSFPivotTable.PivotTableReferenceConfigurator |
POIXMLDocumentPart.RelationPart
Modifier and Type | Field and Description |
---|---|
protected static short |
CREATED_VERSION |
protected static short |
MIN_REFRESHABLE_VERSION |
protected static short |
UPDATED_VERSION |
Modifier | Constructor and Description |
---|---|
protected |
XSSFPivotTable() |
protected |
XSSFPivotTable(PackagePart part)
Creates an XSSFPivotTable representing the given package part and relationship.
|
Modifier and Type | Method and Description |
---|---|
void |
addColLabel(int columnIndex)
Add a col label using data from the given column.
|
void |
addColLabel(int columnIndex,
java.lang.String valueFormat)
Add a col label using data from the given column.
|
void |
addColumnLabel(DataConsolidateFunction function,
int columnIndex)
Add a column label using data from the given column and specified function
|
void |
addColumnLabel(DataConsolidateFunction function,
int columnIndex,
java.lang.String valueFieldName)
Add a column label using data from the given column and specified function
|
void |
addColumnLabel(DataConsolidateFunction function,
int columnIndex,
java.lang.String valueFieldName,
java.lang.String valueFormat)
Add a column label using data from the given column and specified function
|
void |
addDataColumn(int columnIndex,
boolean isDataField)
Add column containing data from the referenced area.
|
void |
addReportFilter(int columnIndex)
Add filter for the column with the corresponding index and cell value
|
void |
addRowLabel(int columnIndex)
Add a row label using data from the given column.
|
protected void |
commit()
Save the content in the underlying package part.
|
protected void |
createDefaultDataColumns() |
protected void |
createSourceReferences(CellReference position,
Sheet sourceSheet,
XSSFPivotTable.PivotTableReferenceConfigurator refConfig)
Creates cacheSource and workSheetSource for pivot table and sets the source reference as well assets the location of the pivot table
|
java.util.List<java.lang.Integer> |
getColLabelColumns() |
org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotTableDefinition |
getCTPivotTableDefinition() |
Sheet |
getDataSheet() |
Sheet |
getParentSheet() |
protected AreaReference |
getPivotArea() |
XSSFPivotCache |
getPivotCache() |
XSSFPivotCacheDefinition |
getPivotCacheDefinition() |
XSSFPivotCacheRecords |
getPivotCacheRecords() |
java.util.List<java.lang.Integer> |
getRowLabelColumns() |
void |
readFrom(java.io.InputStream is) |
void |
setCTPivotTableDefinition(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotTableDefinition pivotTableDefinition) |
protected void |
setDefaultPivotTableDefinition()
Set default values for the table definition.
|
void |
setParentSheet(XSSFSheet parentSheet) |
void |
setPivotCache(XSSFPivotCache pivotCache) |
void |
setPivotCacheDefinition(XSSFPivotCacheDefinition pivotCacheDefinition) |
void |
setPivotCacheRecords(XSSFPivotCacheRecords pivotCacheRecords) |
_invokeOnDocumentRead, addRelation, createRelationship, createRelationship, createRelationship, getNextPartNumber, getPackagePart, getParent, getRelationById, getRelationId, getRelationPartById, getRelationParts, getRelations, getTargetPart, isCommitted, onDocumentCreate, onDocumentRead, onDocumentRemove, onSave, prepareForCommit, read, rebase, removeRelation, removeRelation, removeRelation, setCommitted, toString
protected static final short CREATED_VERSION
protected static final short MIN_REFRESHABLE_VERSION
protected static final short UPDATED_VERSION
@Beta protected XSSFPivotTable()
@Beta protected XSSFPivotTable(PackagePart part) throws java.io.IOException
part
- - The package part that holds xml data representing this pivot table.java.io.IOException
@Beta public void readFrom(java.io.InputStream is) throws java.io.IOException
java.io.IOException
@Beta public void setPivotCache(XSSFPivotCache pivotCache)
@Beta public XSSFPivotCache getPivotCache()
@Beta @Internal public org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotTableDefinition getCTPivotTableDefinition()
@Beta @Internal public void setCTPivotTableDefinition(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotTableDefinition pivotTableDefinition)
@Beta public XSSFPivotCacheDefinition getPivotCacheDefinition()
@Beta public void setPivotCacheDefinition(XSSFPivotCacheDefinition pivotCacheDefinition)
@Beta public XSSFPivotCacheRecords getPivotCacheRecords()
@Beta public void setPivotCacheRecords(XSSFPivotCacheRecords pivotCacheRecords)
@Beta protected void commit() throws java.io.IOException
POIXMLDocumentPart
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(); try (OutputStream out = part.getOutputStream()) { XmlObject bean = getXmlBean(); //the "model" which holds changes in memory bean.save(out, DEFAULT_XML_OPTIONS); } }
commit
in class POIXMLDocumentPart
java.io.IOException
- a subclass may throw an IOException if the changes can't be committed@Beta protected void setDefaultPivotTableDefinition()
protected AreaReference getPivotArea()
@Beta public void addRowLabel(int columnIndex)
columnIndex
- the index of the source column to be used as row label.
columnIndex
is 0-based indexed and relative to the first column in the source.@Beta public java.util.List<java.lang.Integer> getRowLabelColumns()
@Beta public void addColLabel(int columnIndex, java.lang.String valueFormat)
columnIndex
- the index of the source column to be used as row label.
columnIndex
is 0-based indexed and relative to the first column in the source.valueFormat
- format of column value (e.g. for date: "DD.MM.YYYY")@Beta public void addColLabel(int columnIndex)
columnIndex
- the index of the source column to be used as row label.
columnIndex
is 0-based indexed and relative to the first column in the source.@Beta public java.util.List<java.lang.Integer> getColLabelColumns()
@Beta public void addColumnLabel(DataConsolidateFunction function, int columnIndex, java.lang.String valueFieldName, java.lang.String valueFormat)
columnIndex
- the index of the source column to be used as column label.
columnIndex
is 0-based indexed and relative to the first column in the source.function
- the function to be used on the data
The following functions exists:
Sum, Count, Average, Max, Min, Product, Count numbers, StdDev, StdDevp, Var, VarpvalueFieldName
- the name of pivot table value fieldvalueFormat
- format of value field (e.g. "#,##0.00")@Beta public void addColumnLabel(DataConsolidateFunction function, int columnIndex, java.lang.String valueFieldName)
columnIndex
- the index of the source column to be used as column label.
columnIndex
is 0-based indexed and relative to the first column in the source.function
- the function to be used on the data
The following functions exists:
Sum, Count, Average, Max, Min, Product, Count numbers, StdDev, StdDevp, Var, VarpvalueFieldName
- the name of pivot table value field@Beta public void addColumnLabel(DataConsolidateFunction function, int columnIndex)
columnIndex
- the index of the source column to be used as column label
columnIndex
is 0-based indexed and relative to the first column in the source..function
- the function to be used on the data
The following functions exists:
Sum, Count, Average, Max, Min, Product, Count numbers, StdDev, StdDevp, Var, Varp@Beta public void addDataColumn(int columnIndex, boolean isDataField)
columnIndex
- the index of the column containing the dataisDataField
- true if the data should be displayed in the pivot table.@Beta public void addReportFilter(int columnIndex)
columnIndex
- index of column to filter on@Beta protected void createSourceReferences(CellReference position, Sheet sourceSheet, XSSFPivotTable.PivotTableReferenceConfigurator refConfig)
position
- Position for pivot table in sheetsourceSheet
- Sheet where the source will be collected fromrefConfig
- an configurator that knows how to configure pivot table references@Beta protected void createDefaultDataColumns()
Copyright 2022 The Apache Software Foundation or its licensors, as applicable.