FORMULA: Cell Formula (06h)

A FORMULA record describes a cell that contains a formula.

Record Data

Offset
Name
Size
Contents
0 rw 2 Row
2 col 1 Column
3 ixfe 2 Index to XF record
5 num 8 Current value of formula
13 grbit 1 Option flags
14 cce 2 Length of parsed expression, in bytes
16 rgce Variable Parsed expression

Parameters

grbit
The grbit field contains the following option flags.
Bits
Mask
Name
Contents
0 01h fAlwaysCalc Always calculate the formula
2 04h fCirc Formula is part of a circular reference

rw
The rw field contains the zero-based row number.
col
The col field contains the zero-based column number.
num
If the formula evaluates to a number, the num field contains the current calculated value of the formula in 8-byte IEEE format. If the formula evaluates to a string, a Boolean, or an error value, the most-significant 2 bytes of the num field are FFFFh.

A Boolean value is stored in the num field as shown in the following table.
Offset
Name
Size
Contents
0 otBool 1 =1, always
1 Reserved 1 Must be zero
2 f 1 Boolean value
3 Reserved 3 Must be zero
6 fExpr0 2 = FFFFh, always

An error value is stored in the num field as shown in the following table.
Offset
Name
Size
Contents
0 otErr 1 = 2, always
1 Reserved 1 Must be zero
2 err 1 Error value
3 Reserved 3 Must be zero
6 fExpr0 2 = FFFFh, always

If the formula evaluates to a string, the num field has the structure shown in the following table. The string value is not stored in the num field; instead, it is stored in a STRING record that immediately follows the FORMULA record.
Offset
Name
Size
Contents
0 otString 1 = 0, always
1 Reserved 5 Must be zero
6 fExpr0 2 = FFFFh, always

For Pocket Excel 2.0, if the formula evaluates to a blank string, the num field has the following structure No STRING record is generated in this case.
Offset
Name
Size
Contents
0 otBlankString 1 = 3, always
1 Reserved 5 Must be zero
6 fExpr0 2 = FFFFH

rgce
The rgce field contains the formula in its parsed format.