Top Description Fields Constructors Methods
org.apache.poi.hssf.record.aggregates

public final Class FormulaRecordAggregate

extends RecordAggregate
implements CellValueRecordInterface
Class Inheritance
All Implemented Interfaces
org.apache.poi.hssf.record.CellValueRecordInterface
Imports
org.apache.poi.hssf.record.ArrayRecord, .CellValueRecordInterface, .FormulaRecord, .Record, .SharedFormulaRecord, .StringRecord, org.apache.poi.hssf.util.CellRangeAddress8Bit, org.apache.poi.ss.formula.Formula, org.apache.poi.ss.formula.ptg.ExpPtg, .Ptg, org.apache.poi.ss.usermodel.FormulaError, org.apache.poi.ss.util.CellRangeAddress, .CellReference, org.apache.poi.util.RecordFormatException

The formula record aggregate is used to join together the formula record and it's (optional) string record and (optional) Shared Formula Record (template reads, excel optimization).

Field Summary

Modifier and TypeField and Description
private final FormulaRecord
private SharedFormulaRecord
private SharedValueManager
private StringRecord
_stringRecord

caches the calculated result of the formula

Constructor Summary

AccessConstructor and Description
public
FormulaRecordAggregate(FormulaRecord formulaRec, StringRecord
may be null if this formula does not have a cached text value.
stringRec
,
SharedValueManager
the SharedValueManager for the current sheet
svm
)

Method Summary

Modifier and TypeMethod and Description
public CellRangeAddress
public short
public FormulaRecord
public Ptg[]
public int
public StringRecord
getStringRecord()

debug only TODO - encapsulate

public String
public short
private static void
handleMissingSharedFormulaRecord(FormulaRecord formula)

Sometimes the shared formula flag "seems" to be erroneously set (because the corresponding SharedFormulaRecord does not exist).

public boolean
public void
notifyFormulaChanging()

Should be called by any code which is either deleting this formula cell, or changing its type.

public CellRangeAddress

Returns:

the range of the array formula containing the specified cell. Never null
removeArrayFormula
(int rowIndex, int columnIndex)

Removes an array formula

public void
public void
setCachedBooleanResult(boolean value)

public void
setCachedDoubleResult(double value)

public void
setCachedErrorResult(int errorCode)

public void
public void
public void
setColumn(short
the column this cell defines
col
)

Implements org.apache.poi.hssf.record.CellValueRecordInterface.setColumn.

public void
setParsedExpression(Ptg[] ptgs)

Also checks for a related shared formula and unlinks it if found

public void
setRow(int
the row this cell occurs within
row
)

Implements org.apache.poi.hssf.record.CellValueRecordInterface.setRow.

public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
public void
visitContainedRecords(RecordAggregate.RecordVisitor
The visitor to use for callbacks while walking this object
rv
)

Implements abstract org.apache.poi.hssf.record.aggregates.RecordAggregate.visitContainedRecords.

Visit each of the atomic BIFF records contained in this RecordAggregate in the order that they should be written to file.

Inherited from org.apache.poi.hssf.record.aggregates.RecordAggregate:
getRecordSizeserialize

Field Detail

_formulaRecordback to summary
private final FormulaRecord _formulaRecord
_sharedFormulaRecordback to summary
private SharedFormulaRecord _sharedFormulaRecord
_sharedValueManagerback to summary
private SharedValueManager _sharedValueManager
_stringRecordback to summary
private StringRecord _stringRecord

caches the calculated result of the formula

Constructor Detail

FormulaRecordAggregateback to summary
public FormulaRecordAggregate(FormulaRecord formulaRec, StringRecord stringRec, SharedValueManager svm)
Parameters
stringRec:StringRecord

may be null if this formula does not have a cached text value.

svm:SharedValueManager

the SharedValueManager for the current sheet

Method Detail

getArrayFormulaRangeback to summary
public CellRangeAddress getArrayFormulaRange()
getColumnback to summary
public short getColumn()

Implements org.apache.poi.hssf.record.CellValueRecordInterface.getColumn.

Returns:short

Doc from org.apache.poi.hssf.record.CellValueRecordInterface.getColumn.

the column this cell defines within the row

getFormulaRecordback to summary
public FormulaRecord getFormulaRecord()
getFormulaTokensback to summary
public Ptg[] getFormulaTokens()
getRowback to summary
public int getRow()

Implements org.apache.poi.hssf.record.CellValueRecordInterface.getRow.

Returns:int

Doc from org.apache.poi.hssf.record.CellValueRecordInterface.getRow.

the row this cell occurs on

getStringRecordback to summary
public StringRecord getStringRecord()

debug only TODO - encapsulate

getStringValueback to summary
public String getStringValue()
getXFIndexback to summary
public short getXFIndex()

Implements org.apache.poi.hssf.record.CellValueRecordInterface.getXFIndex.

handleMissingSharedFormulaRecordback to summary
private static void handleMissingSharedFormulaRecord(FormulaRecord formula)

Sometimes the shared formula flag "seems" to be erroneously set (because the corresponding SharedFormulaRecord does not exist). Normally this would leave no way of determining the Ptg tokens for the formula. However as it turns out in these cases, Excel encodes the unshared Ptg tokens in the right place (inside the FormulaRecord). So the only thing that needs to be done is to ignore the erroneous shared formula flag.
This method may also be used for setting breakpoints to help diagnose issues regarding the abnormally-set 'shared formula' flags. (see TestValueRecordsAggregate.testSpuriousSharedFormulaFlag()).

isPartOfArrayFormulaback to summary
public boolean isPartOfArrayFormula()
notifyFormulaChangingback to summary
public void notifyFormulaChanging()

Should be called by any code which is either deleting this formula cell, or changing its type. This method gives the aggregate a chance to unlink any shared formula that may be involved with this cell formula.

removeArrayFormulaback to summary
public CellRangeAddress removeArrayFormula(int rowIndex, int columnIndex)

Removes an array formula

Returns:CellRangeAddress

the range of the array formula containing the specified cell. Never null

setArrayFormulaback to summary
public void setArrayFormula(CellRangeAddress r, Ptg[] ptgs)
setCachedBooleanResultback to summary
public void setCachedBooleanResult(boolean value)
setCachedDoubleResultback to summary
public void setCachedDoubleResult(double value)
setCachedErrorResultback to summary
public void setCachedErrorResult(int errorCode)
setCachedErrorResultback to summary
public void setCachedErrorResult(FormulaError error)
setCachedStringResultback to summary
public void setCachedStringResult(String value)
setColumnback to summary
public void setColumn(short col)

Implements org.apache.poi.hssf.record.CellValueRecordInterface.setColumn.

Parameters
col:short

Doc from org.apache.poi.hssf.record.CellValueRecordInterface.setColumn.

the column this cell defines

setParsedExpressionback to summary
public void setParsedExpression(Ptg[] ptgs)

Also checks for a related shared formula and unlinks it if found

setRowback to summary
public void setRow(int row)

Implements org.apache.poi.hssf.record.CellValueRecordInterface.setRow.

Parameters
row:int

Doc from org.apache.poi.hssf.record.CellValueRecordInterface.setRow.

the row this cell occurs within

setXFIndexback to summary
public void setXFIndex(short xf)

Implements org.apache.poi.hssf.record.CellValueRecordInterface.setXFIndex.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

unlinkSharedFormulaback to summary
public void unlinkSharedFormula()
visitContainedRecordsback to summary
public void visitContainedRecords(RecordAggregate.RecordVisitor rv)

Implements abstract org.apache.poi.hssf.record.aggregates.RecordAggregate.visitContainedRecords.

Doc from org.apache.poi.hssf.record.aggregates.RecordAggregate.visitContainedRecords.

Visit each of the atomic BIFF records contained in this RecordAggregate in the order that they should be written to file. Implementors may or may not return the actual Records being used to manage POI's internal implementation. Callers should not assume either way, and therefore only attempt to modify those Records after cloning

Parameters
rv:RecordAggregate.RecordVisitor

The visitor to use for callbacks while walking this object

Annotations
@Override