FORMULA: Cell Formula (406h)

A FORMULA record describes a cell that contains a formula.

Record Data

Offset

Name

Size

Contents

4

rw

2

Row

6

col

2

Column

8

ixfe

2

Index to XF record

10

num

8

Current value of the formula (see text)


Offset

Name

Size

Contents

18

grbit

2

Option flags

20

chn

4

(See text)

24

cce

2

Length of the parsed expression

26

rgce

var

Parsed expression


The chn field should be ignored when you read the BIFF file. If you write a BIFF file, the chn field must be 00000000h.

The grbit field contains the option flags listed in the following table.

Offset

Bits

Mask

Name

Contents

0

0

01h

fAlwaysCalc

Always calculate the formula.

1

02h

fCalcOnLoad

Calculate the formula when the file is opened.

2

04h

(Reserved)

3

08h

fShrFmla

= 1 if the formula is part of shared formula group.

7–4

F0h

(Unused)

1

7–0

FFh

(Unused)


For more information about shared formulas, see "SHRFMLA" on page 386.

The rw field contains the 0-based row number. The col field contains the 0-based column number.

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 value, 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. For more information about Boolean values, see "BOOLERR" on page 290.

Offset

Name

Size

Contents

0

otBool

1

= 1 always

1

(Reserved)

1

Reserved; must be 0 (zero)

2

f

1

Boolean value

3

(Reserved)

3

Reserved; must be 0 (zero)

6

fExprO

2

= FFFFh


An error value is stored in the num field, as shown in the following table. For more information about error values, see "BOOLERR" on page 290.

Offset

Name

Size

Contents

0

otErr

1

= 2 always

1

(Reserved)

1

Reserved; must be 0 (zero)

2

err

1

Error value

3

(Reserved)

3

Reserved; must be 0 (zero)

6

fExprO

2

= FFFFh


If the formula evaluates to a string, the num field has the structure shown in the following table.

Offset

Name

Size

Contents

0

otString

1

= 0 always

1

(Reserved)

5

Reserved; must be 0 (zero)

6

fExprO

2

= FFFFh


The string value is not stored in the num field; instead, it is stored in a STRING record that immediately follows the FORMULA record.

The cce field contains the length of the formula. The rgce field contains the formula in its parsed format. For more information, see "Microsoft Excel Formulas" on page 444.