In This Topic
Provides a formula expression.
Object Model
Syntax
'Declaration
Public MustInherit Class FormulaExpression
public abstract class FormulaExpression
public __gc abstract class FormulaExpression
public ref class FormulaExpression abstract
Example
This C#/VB.NET code shows how to set the expression for focused formula in the spreadsheet visual editor.
Friend Class SpreadsheetVisualEditorExamples
'[BLOCK:FocusedFormulaExpression]
''' <summary>
''' Sets the formula for focused cell of a spreadsheet document.
''' </summary>
''' <param name="visualEditor">VintaSoft control that allows to display and edit spreadsheet document.</param>
''' <param name="formula">Formula that will be set for focused cell.</param>
Public Shared Sub SetFocusedFormulaExpression(visualEditor As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor, formula As String)
Try
' create the formula expression for focused cell on focused worksheet
Dim formulaExpression As Vintasoft.Imaging.Office.Spreadsheet.Formulas.FormulaExpression = Vintasoft.Imaging.Office.Spreadsheet.Formulas.FormulaParser.Parse(visualEditor.Document, visualEditor.FocusedWorksheet, visualEditor.FocusedCell, formula, False)
' set the focused formula expression in the spreadsheet visual editor
visualEditor.FocusedFormulaExpression = formulaExpression
Catch ex As System.Exception
' show error message
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End Sub
''' <summary>
''' Test for function that sets the formula for focused cell of a spreadsheet document.
''' </summary>
''' <param name="visualEditor">VintaSoft control that allows to display and edit spreadsheet document.</param>
Public Shared Sub TestSetFocusedFormulaExpression(visualEditor As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor)
' set focused formula expression
SetFocusedFormulaExpression(visualEditor, "SUM(A2:B5)")
End Sub
'[ENDBLOCK]
End Class
namespace CSHARP
{
internal class SpreadsheetVisualEditorExamples
{
//[BLOCK:FocusedFormulaExpression]
/// <summary>
/// Sets the formula for focused cell of a spreadsheet document.
/// </summary>
/// <param name="visualEditor">VintaSoft control that allows to display and edit spreadsheet document.</param>
/// <param name="formula">Formula that will be set for focused cell.</param>
public static void SetFocusedFormulaExpression(Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor visualEditor, string formula)
{
try
{
// create the formula expression for focused cell on focused worksheet
Vintasoft.Imaging.Office.Spreadsheet.Formulas.FormulaExpression formulaExpression =
Vintasoft.Imaging.Office.Spreadsheet.Formulas.FormulaParser.Parse(
visualEditor.Document, visualEditor.FocusedWorksheet, visualEditor.FocusedCell, formula, false);
// set the focused formula expression in the spreadsheet visual editor
visualEditor.FocusedFormulaExpression = formulaExpression;
}
catch (System.Exception ex)
{
// show error message
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
/// <summary>
/// Test for function that sets the formula for focused cell of a spreadsheet document.
/// </summary>
/// <param name="visualEditor">VintaSoft control that allows to display and edit spreadsheet document.</param>
public static void TestSetFocusedFormulaExpression(Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor visualEditor)
{
// set focused formula expression
SetFocusedFormulaExpression(visualEditor, "SUM(A2:B5)");
}
//[ENDBLOCK]
}
}
Inheritance Hierarchy
System.Object
 Vintasoft.Imaging.Office.Spreadsheet.Formulas.FormulaExpression
Requirements
Target Platforms: .NET9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5
See Also