VintaSoft Imaging .NET SDK 15.1: Documentation for .NET developer
Vintasoft.Imaging.Office.Spreadsheet.Formulas Namespace / FormulaExpression Class
Members Object Syntax Example Hierarchy Requirements SeeAlso
In This Topic
FormulaExpression Class
In This Topic
Provides a formula expression.
Object Model
CellReferencesSet FormulaExpression
Syntax
'Declaration

Public MustInherit Class FormulaExpression

public abstract class FormulaExpression

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: .NET 10; .NET 9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

See Also