Formulas in Spreadsheet for WinForms
To create a formula in a cell, use the CellRange.Formula property of the Cell object. Assign the required formula to this property as a string starting with the equals sign (“=”).
This example demonstrates how to create a simple formula using constants and calculation operators, and add this formula to a cell. Constants are values that are not calculated (e.g., date values, numbers, text strings). Operators specify what calculations should be performed on a formula’s elements.
// Use constants and calculation operators in a formula.
workbook.Worksheets[0].Cells["B2"].Formula = "= (1+5)*6";
The following examples demonstrate how to create and use different formulas in cells:
- How to: Create Formulas Using Cell References
- How to: Create Formulas Using Cell Names
- How to: Create Formulas Using Functions
- How to: Create Array Formulas
- How to: Create Shared Formulas
- How to: Create Custom Functions
- How to: Use Excel Add-Ins in the Spreadsheet Control
- How to: Create a Custom Function that Returns an Array
See Also