Package org.apache.poi.ss.formula
Class Formula
java.lang.Object
org.apache.poi.ss.formula.Formula
- All Implemented Interfaces:
GenericRecord
Encapsulates an encoded formula token array.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopy()static FormulaCreates a Formula object from a suppliedPtgarray.intintThis method is often used when the formula length does not appear immediately before the encoded token data.Gets the locator for the correspondingSharedFormulaRecord,ArrayRecordorTableRecordif this formula belongs to such a grouping.Ptg[]static Ptg[]Gets thePtgarray from the supplied Formula.booleanstatic Formularead(int encodedTokenLen, LittleEndianInput in) Convenience method forread(int, LittleEndianInput, int)static Formularead(int encodedTokenLen, LittleEndianInput in, int totalEncodedLen) When there are no array constants present,encodedTokenLen==totalEncodedLenvoidWrites The formula encoding is includes: ushort tokenDataLen tokenData arrayConstantData (if present)voidvoidMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.poi.common.usermodel.GenericRecord
getGenericChildren, getGenericRecordType
-
Constructor Details
-
Formula
-
-
Method Details
-
read
Convenience method forread(int, LittleEndianInput, int) -
read
When there are no array constants present,encodedTokenLen==totalEncodedLen- Parameters:
encodedTokenLen- number of bytes in the stream taken by the plain formula tokenstotalEncodedLen- the total number of bytes in the formula (includes trailing encoding for array constants, but does not include 2 bytes for initialushort encodedTokenLenfield.- Returns:
- A new formula object as read from the stream. Possibly empty, never
null.
-
getTokens
-
serialize
Writes The formula encoding is includes:- ushort tokenDataLen
- tokenData
- arrayConstantData (if present)
-
serializeTokens
-
serializeArrayConstantData
-
getEncodedSize
public int getEncodedSize()- Returns:
- total formula encoding length. The formula encoding includes:
- ushort tokenDataLen
- tokenData
- arrayConstantData (optional)
tokenDataLength
-
getEncodedTokenSize
public int getEncodedTokenSize()This method is often used when the formula length does not appear immediately before the encoded token data.- Returns:
- the encoded length of the plain formula tokens. This does not include the leading ushort field, nor any trailing array constant data.
-
create
Creates a Formula object from a suppliedPtgarray. Handlesnulls OK.- Parameters:
ptgs- may benull- Returns:
- Never
null(Possibly empty if the suppliedptgsisnull)
-
getTokens
Gets thePtgarray from the supplied Formula. Handlesnulls OK.- Parameters:
formula- may benull- Returns:
- possibly
null(if the suppliedformulaisnull)
-
copy
-
getExpReference
Gets the locator for the correspondingSharedFormulaRecord,ArrayRecordorTableRecordif this formula belongs to such a grouping. TheCellReferencereturned by this method will match the top left corner of the range of that grouping. The return value is usually not the same as the location of the cell containing this formula.- Returns:
- the firstRow & firstColumn of an array formula or shared formula that this formula
belongs to.
nullif this formula is not part of an array or shared formula.
-
isSame
-
getGenericProperties
- Specified by:
getGenericPropertiesin interfaceGenericRecord
-