wpf-16299-controls-and-libraries-spreadsheet-formulas.md
A spreadsheet formula is an equation that performs a calculation on the numbers, functions, and values of one or more cells. A formula is associated with a cell or a cell range. It is accessed by the CellRange.Formula property.
| Formula Type | Description | More Information |
|---|---|---|
| Normal | Use the CellRange.Formula property to assign a formula to a cell or to each cell in a range. | Create Formulas |
| Shared | Shared formula is created automatically when required without user intervention when you assign a formula string to an array of cells. A specified formula is associated with each cell contained within the specified cell range. Shared formulas are used internally to optimize calculations and file size. | How to: Create Shared Formulas |
| Array | An array formula | Array Formulas |
A formula is a string expression that begins with an equal (=) sign. A formula can contain the constants, operators, cell references, calls to functions, and names.
Consider the following formula, which calculates the mass of a sphere.
=4/3_PI()_(A2^3)*Density
The formula is calculated from left to right, according to the operator precedence. To change the order of calculation you can enclose a portion of the formula in parentheses.
To recalculate all formulas in a workbook, call the IWorkbook.Calculate method. The DocumentSettings.Calculation property provides access to calculation options. Calculation results are placed in the CellRange.Value property of corresponding cells. See the Calculation topic for more information.
You can also calculate a formula and leave the document unchanged by using the IWorkbook.Evaluate method.
The FormulaEngine is an object that provides the capability to calculate and parse worksheet formulas. It includes a built-in formula parser, as well as the flexibility to evaluate formulas in any range of any worksheet. See the Formula Engine topic for more information.
See Also