Formulas
Setting a formula and knowing its result are two different operations. A cell
holds the formula text and a cached value, and they are stored separately in the
file. SetFormulaRaw writes the text and clears the value, so nothing is
computed and the cell reads as empty until something evaluates it. Excel
recalculates when it opens a workbook, which is why a file with no cached values
at all still looks correct on screen. Anything that reads the file without a
formula engine, including a later UniOffice program, sees the blank.
Evaluation is what fills those values in. Workbook.RecalculateFormulas runs
UniOffice’s own engine over every sheet and writes the result of each formula
back as its cached value, leaving the formulas in place. A formula.Evaluator
does the same work for one expression at a time and hands the result back to your
program instead of to the file. The engine implements 231 functions and an
incomplete grammar; anything it cannot compute, including a function it does not
know, leaves the cached value empty rather than writing an error, so Excel
recovers on open.
Flattening goes further and is not a variant of evaluating. It clears each cell
and writes the computed value as the cell’s own value, so the formulas are gone
from the saved file. That is what you want for a report nobody should re-run, and
it is a trap for a workbook using functions the engine lacks, because those
flatten to a permanent #VALUE!.
Shared formulas are a size optimization, not a different semantics. One
definition covers a rectangular block, with relative references offset per cell
and $ suppressing the offset, exactly as filling a formula down a column in
Excel does. The file gets smaller and Excel reads it identically.
The last three guides are about referring to cells rather than computing with them: parsing a reference string into its parts, placing a cell in a specific column, and giving a range a name that formulas and chart series can use.
Where to look
| Guide | Covers |
|---|---|
| Set a Formula | Writing formula text into a cell, and the three setters. |
| Evaluate Formulas | Running the engine, reading results, function coverage. |
| Shared Formulas | One definition covering a block, and how offsets work. |
| Flatten Formulas | Replacing formulas with their computed values. |
| Parse References | Splitting cell and range references into their parts. |
| Name a Cell Range | Defined names, and using them in formulas and charts. |