public final class Formula extends XLSCellRecord
offset name size contents 0 rw 2 Row 2 col 2 Column 4 ixfe 2 Index to the XF record 6 num 8 Current value of the formula 14 grbit 2 Option Flags 16 chn 4 (Reserved, must be zero) A field that specifies an application-specific cache of information. This cache exists for performance reasons only, and can be rebuilt based on information stored elsewhere in the file without affecting calculation results. 20 cce 2 Parsed Expression length 22 rgce cce Parsed ExpressionThe grbit field contains the following flags:
byte bits mask name asserted if
0 0 0x01 fAlwaysCalc the result must not be cached
1 0x02 fCalcOnLoad the cached value is incorrect
2 0x04 (Reserved)
3 0x08 fShrFmla this is a reference to a shared formula
7-4 0xF0 (Unused)
1 7-0 0xFF (Unused)
In most cases, formulas should have fAlwaysCalc asserted to ensure that
correct values are displayed upon opening of the file in Excel.CellAddressible.ColumnMajorComparator, CellAddressible.RangeBoundary, CellAddressible.Reference, CellAddressible.RowMajorComparatorColumnRange.Comparator| Modifier and Type | Field and Description |
|---|---|
Shrfmla |
shared
The target ShrFmla record, if this is a shared formula reference.
|
col, continues, DEBUGLEVEL, hyperlink, idx, isBlank, isBoolean, isContinueMerged, isString, lastidx, myxf, offset, rw, streamer, wkbook, worksheetAI, ALLOWDUPES, ALRUNS, AREA, AREAFORMAT, ARRAY, ATTACHEDLABEL, AUTOFILTER, AXCENT, AXESUSED, AXIS, AXISLINEFORMAT, AXISPARENT, BACKUP, BAR, BEGIN, BLANK, BOF, BOOKBOOL, BOOLERR, BOPPOP, BOPPOPCUSTOM, BOTTOM_MARGIN, BOTTOMMARGIN, BOUNDSHEET, CALC_MODE_PROP, CALCCOUNT, CALCMODE, CALCULATE_ALWAYS, CALCULATE_AUTO, CALCULATE_EXPLICIT, CATLAB, CATSERRANGE, CF, CF12, CHART, CHART3DBARSHAPE, CHARTFORMAT, CHARTFORMATLINK, CHARTFRTINFO, CHARTLINE, CODENAME, COLINFO, CONDFMT, CONDFMT12, CONTINUE, COUNTRY, CRN, CRTLAYOUT12, CRTLAYOUT12A, DAT, DATAFORMAT, DATALABEXT, DATALABEXTCONTENTS, DATE1904, DBCELL, DCON, DCONBIN, DCONNAME, DCONREF, DEBUG_HIGH, DEBUG_LOW, DEBUG_MEDIUM, DEFAULTENCODING, DEFAULTROWHEIGHT, DEFAULTTEXT, DEFCOLWIDTH, DELTA, DIMENSIONS, DROPBAR, DSF, DV, DVAL, END, ENDBLOCK, ENDEXTSST, ENDOBJECT, EOF, EXCEL2K, EXTERNCOUNT, EXTERNNAME, EXTERNSHEET, EXTSST, FBI, FEATHEADR, FILE_LOCK, FILEPASS, FONT, FONTBASIS, FONTX, FOOTERREC, FORMAT, FORMULA, FRAME, FRTFONTLIST, FRTWRAPPER, GARBAGE, GELFRAME, GUTS, HCENTER, HEADERREC, HLINK, HORIZONTAL_PAGE_BREAKS, IFMT, INDEX, INTERFACE_HDR, ITERATION, LABEL, LABELSST, LEFT_MARGIN, LEFTMARGIN, LEGEND, LEGENDXN, LINE, LINEFORMAT, MARKERFORMAT, MAXCOLS, MAXCOLS_BIFF8, MAXRECLEN, MAXROWS, MAXROWS_BIFF8, MERGEDCELLS, MSODRAWING, MSODRAWINGGROUP, MSODRAWINGSELECTION, MULBLANK, MULRK, NAME, NOTE, NUMBER, OBJ, OBJECTLINK, OBJPROTECT, OBPROJ, PALETTE, PANE, PASSWORD, PHONETIC, PICF, PIE, PIEFORMAT, PIVOTCHARTBITS, PIVOTCHARTLINK, PLOTAREA, PLOTGROWTH, PLS, PLV, POS, PRECISION, PRINT_GRIDLINES, PRINT_ROW_HEADERS, PRINTGRID, PRINTROWCOL, PROT4REV, PROTECT, QSISXTAG, RADAR, RADARAREA, RANGEPROTECTION, REFMODE, REFTRACK_PROP, RIGHT_MARGIN, RIGHTMARGIN, RK, ROW, RRD_HEAD, RRD_INFO, RSTRING, RTENTEXU, RTMERGECELLS, SBASEREF, SCATTER, SCENPROTECT, SCL, SELECTION, SERAUXERRBAR, SERAUXTREND, SERFMT, SERIES, SERIESLIST, SERIESTEXT, SERPARENT, SERTOCRT, SETUP, SHAREDUPES, SHEETLAYOUT, SHEETPROTECTION, SHRFMLA, SHTPROPS, SIIINDEX, SST, STARTBLOCK, STARTOBJECT, STRING_ENCODING_AUTO, STRING_ENCODING_COMPRESSED, STRING_ENCODING_UNICODE, STRINGREC, STYLE, SUPBOOK, SURFACE, SXADDL, SXBOOL, SXDB, SXDBB, SXDBEX, SXDI, SXEX, SXFDB, SXFDBTYPE, SXFORMAT, SXIVD, SXLI, SXNUM, SXPI, SXSTREAMID, SXSTRING, SXVD, SXVDEX, SXVI, SXVIEW, SXVIEWEX9, SXVIEWLINK, SXVS, TABID, TABLE, TABLESTYLES, TEXTDISP, THREED, TICK, TOP_MARGIN, TOPMARGIN, TXO, TYPE_BLANK, TYPE_BOOLEAN, TYPE_DOUBLE, TYPE_FORMULA, TYPE_FP, TYPE_INT, TYPE_STRING, UNICODEENCODING, UNITS, USERBVIEW, USERSVIEWBEGIN, USERSVIEWEND, USETEMPFILE_PROP, USR_EXCL, VALIDATEWORKBOOK, VALUERANGE, VB_MODULE, VCENTER, VERTICAL_PAGE_BREAKS, WINDOW_PROTECT, WINDOW1, WINDOW2, WK_CHART, WK_FILE, WK_GLOBALS, WK_MACROSHEET, WK_WORKSHEET, WSBOOL, XCT, XF, XLS_MAX_COLS, YMULT| Constructor and Description |
|---|
Formula()
Default constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
addInternalRecord(BiffRec b)
store formula-associated records: one or more of:
ShrFmla
StringRec
Array
|
Object |
calculate()
Calculate the formula if necessary.
|
Object |
calculateFormula()
Calculates the formula honoring calculation mode.
|
protected void |
calculateIndirectFunction()
If the method contains an indirect function then
register those ptgs into the reference tracker.
|
void |
clearCachedValue()
Set the cached value of this formula,
in cases where the formula is null, set the cache to null,
as welll as updating the attached string to null in order to force
recalc
|
Object |
clone()
clone a record
|
void |
close()
clear out object references in prep for closing workbook
|
void |
convertSharedFormula()
Converts a shared formula reference into a normal formula.
|
void |
destroy()
Performs cleanup needed before removing the formula cell from the
work sheet.
|
protected void |
finalize() |
Array |
getArray()
fetches the internal Array record linked to this formula, if any,
or null if not an array formula
|
String |
getArrayRefs() |
StringRec |
getAttatchedString()
Get the String that is attached to this formula (it has a result of a string..);
|
boolean |
getBooleanVal()
Get the value of the record as a Boolean.
|
boolean |
getCalcAlways()
return the "Calculate Always" setting for this formula
used for formulas that always need calculating such as TODAY
|
Ptg[] |
getCellRangePtgs()
Returns an array of ptgs that represent any BiffRec ranges in the formula.
|
double |
getDblVal()
Get the value of the record as a Double.
|
Stack |
getExpression()
get the expression stack
|
float |
getFloatVal()
Get the value of the record as a Float.
|
String |
getFormulaString()
Returns the Human-Readable String Representation of
this Formula.
|
List |
getInternalRecords() |
int |
getIntVal()
Get the value of the formula as an integer.
|
List |
getPtgsByLocation(String loc)
Returns the ptg that matches the string location sent to it.
|
String |
getStringVal()
return the String representation of the current Formula value
|
String |
getTypeName() |
boolean |
hasAttachedString() |
static void |
incrementSharedFormula(Stack origStack,
int rowInc,
int colInc,
int[] range)
increment each PtgRef in expression stack via row or column based
on rowInc or colInc values
Used in OOXML parsing
|
void |
init()
Parses the record bytes.
|
boolean |
isArrayFormula()
return truth of "this is an array formula" i.e.
|
static boolean |
isErrorValue(String s)
returns true if the value s is one of the Excel defined Error Strings
|
boolean |
isSharedFormula()
Returns whether this is a reference to a shared formula.
|
void |
preStream()
Updates the record data if necessary to prepare for streaming.
|
protected void |
registerIndirectFunction()
Adds an indirect function to the list of functions to be evaluated post load
|
void |
removeInternalRecord(BiffRec b) |
void |
replacePtg(Ptg thisptg,
Ptg ptgErr)
Replaces a ptg in the active expression.
|
void |
setArrayRefs(String s)
OOXML-specific: set the range the Array references
|
void |
setCachedValue(Object newValue)
Set the cached value of this formula,
in cases where the formula is null, set the cache to null,
as well as updating the attached string to null in order to force
recalc
|
void |
setCalcAlways(boolean fAlwaysCalc)
set the "Calculate Always setting for this formula
used for formulas that always need calculating such as TODAY
|
protected void |
setContainsIndirectFunction(boolean containsIndirectFunction)
Set if the formula contains Indirect()
|
void |
setExpression(Stack exp)
for creating a formula on the fly.
|
void |
setIsExternalRef(boolean isExternalRef)
set if this formula refers to External References
(references defined in other workbooks)
|
boolean |
setLocationPolicy(String loc,
int l)
locks the Ptg at the specified location
|
void |
setStringVal(String v) |
String |
toString() |
void |
updateRecord()
Called to indicate that the parsed expression has changed.
|
getColFirst, getColLast, isSingleColaddContinue, copyFormat, getByteAt, getByteReader, getBytes, getBytesAt, getCellAddress, getCellAddressWithSheet, getCellType, getColNumber, getColorTable, getContinueVect, getData, getDataType, getDefaultVal, getEncryptedByteReader, getFirstBlock, getFont, getFormatPattern, getFormulaRec, getHyperlink, getInternalVal, getIntLocation, getIxfe, getLastBlock, getLength, getMergeRange, getOffset, getOpcode, getPrototype, getRealRecordIndex, getRecDesc, getRecordIndex, getRow, getRowNumber, getSheet, getStreamer, getStringVal, getWorkBook, getXfRec, hasContinues, initRowCol, isFormula, isNumber, isReadOnly, isValueForCell, mergeContinues, postStream, remove, removeContinues, resetCacheBytes, setBooleanVal, setByteReader, setCol, setData, setDebugLevel, setDoubleVal, setEncryptedByteReader, setFirstBlock, setFloatVal, setHyperlink, setIndex, setIntVal, setIsValueForCell, setIxfe, setLastBlock, setLength, setMergeRange, setOffset, setOpcode, setRow, setRowCol, setRowNumber, setSheet, setStreamer, setValueForCell, setWorkBook, setXFRecord, setXFRecord, shouldEncrypt, toHexDumpequals, getClass, hashCode, notify, notifyAll, wait, wait, waitaddContinue, copyFormat, getByteAt, getByteReader, getBytes, getBytesAt, getCellAddress, getColNumber, getContinueVect, getData, getDataType, getDefaultVal, getEncryptedByteReader, getFont, getFormatPattern, getFormulaRec, getHyperlink, getInternalVal, getIxfe, getLength, getMergeRange, getOffset, getOpcode, getRecordIndex, getRow, getRowNumber, getSheet, getStreamer, getStringVal, getWorkBook, getXfRec, hasContinues, isReadOnly, isValueForCell, postStream, remove, removeContinues, setBooleanVal, setByteReader, setCol, setData, setDebugLevel, setDoubleVal, setEncryptedByteReader, setHyperlink, setIndex, setIntVal, setIsValueForCell, setIxfe, setLength, setMergeRange, setOffset, setOpcode, setRow, setRowCol, setRowNumber, setSheet, setStreamer, setWorkBook, setXFRecord, setXFRecord, toHexDumpgetRowNumberpublic Shrfmla shared
public void init()
public void setExpression(Stack exp)
public Stack getExpression()
public void addInternalRecord(BiffRec b)
b - public void removeInternalRecord(BiffRec b)
public List getInternalRecords()
public boolean hasAttachedString()
public StringRec getAttatchedString()
public boolean getCalcAlways()
public void setCalcAlways(boolean fAlwaysCalc)
fAlwaysCalc - public void setIsExternalRef(boolean isExternalRef)
isExternalRef - public String getTypeName()
protected void registerIndirectFunction()
protected void calculateIndirectFunction()
public void convertSharedFormula()
IllegalStateException - if this is not a shared formula memberpublic String getFormulaString()
public List getPtgsByLocation(String loc) throws FormulaNotFoundException
FormulaNotFoundExceptionpublic Ptg[] getCellRangePtgs() throws FormulaNotFoundException
FormulaNotFoundExceptionpublic boolean setLocationPolicy(String loc, int l)
public void updateRecord()
public void preStream()
public int getIntVal()
throws RuntimeException
getIntVal in interface BiffRecgetIntVal in class XLSRecordRuntimeExceptionXLSRecord.getIntVal()public float getFloatVal()
XLSRecordgetFloatVal in interface BiffRecgetFloatVal in class XLSRecordpublic boolean getBooleanVal()
XLSRecordgetBooleanVal in interface BiffRecgetBooleanVal in class XLSRecordpublic double getDblVal()
XLSRecordpublic String getStringVal()
getStringVal in interface BiffRecgetStringVal in class XLSRecordpublic Object calculateFormula() throws FunctionNotSupportedException
public Object calculate()
CalculationExceptionpublic boolean isSharedFormula()
public void setStringVal(String v)
setStringVal in interface BiffRecsetStringVal in class XLSRecordpublic boolean isArrayFormula()
public Array getArray()
isArrayFormulapublic void setArrayRefs(String s)
s - public void setCachedValue(Object newValue)
io.starter.formats.XLS.XLSRecord#setCachedValue(java.lang.Object)public void clearCachedValue()
io.starter.formats.XLS.XLSRecord#setCachedValue(java.lang.Object)public String getArrayRefs()
public static void incrementSharedFormula(Stack origStack, int rowInc, int colInc, int[] range)
protected void setContainsIndirectFunction(boolean containsIndirectFunction)
containsIndirectFunction - The containsIndirectFunction to set.public void destroy()
public static boolean isErrorValue(String s)
s - public void close()
XLSRecordCopyright © 2002–2019 Starter Inc.. All rights reserved.