Microsoft Office Excel formulae allow you to execute calculations on the data entered in the spreadsheet cells. Using a formula is a method of performing calculations that rely on a recognized approach. VSTO helps Office developers to automate Excel solutions with formulae for calculation in the cells of the spreadsheet.
Formula
is a property of the NamedRange
control in the Microsoft.Office.Tools.Excel
object. If the NamedRange control contains a formula, the Formula
property returns the formula as a string.
Let's see an example of multiplying a range of cell values, and displaying the results in the assigned cell. Open Visual Studio 2008 and create a new solution, as usual. Write the following code in the Sheet1.cs
file:
private void Sheet2_Startup(object sender, System.EventArgs e) { // Range of cell for calculation Microsoft.Office.Tools.Excel.NamedRange AuthorCellRange1 = this.Controls.AddNamedRange(this.Range["B1", "B2"], "AuthorNamedRange1"); // Cell range to display...