VintaSoft Imaging .NET SDK 15.1: Documentation for .NET developer
In This Topic
XLSX: Work with formulas on XLSX page
In This Topic
SpreadsheetEditorControl and WpfSpreadsheetEditorControl controls allow to work (view, add, edit and delete) with formulas in cells of XLSX worksheet in desktop (WinForms, WPF) application.
Formulas can be changed visually using mouse/keyboard or programmatically.


Add a formula to the focused cell of XLSX worksheet

Here is C#/VB.NET code that demonstrates how to add a formula to the focused cell of XLSX worksheet:
public void AddFormulaToXlsxCell(Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl editorControl)
{
    // get visual editor for spreadsheet document
    Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor spreadsheetVisualEditor = editorControl.VisualEditor;

    string formula = "ABS(A1)+SUM(B2,B3)";

    // add formula to the focused cell
    spreadsheetVisualEditor.InsertFormulaInFocusedCell(formula);
    // result formula value: "=ABS(A1)+SUM(B2,B3)"
}
Public Sub AddFormulaToXlsxCell(editorControl As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl)
    ' get visual editor for spreadsheet document
    Dim spreadsheetVisualEditor As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor = editorControl.VisualEditor

    Dim formula As String = "ABS(A1)+SUM(B2,B3)"

    ' add formula to the focused cell
    spreadsheetVisualEditor.InsertFormulaInFocusedCell(formula)
    ' result formula value: "=ABS(A1)+SUM(B2,B3)"
End Sub


Change formula of focused cell programmatically

Here is C#/VB.NET code that demonstrates how to change a formula of focused cell of XLSX worksheet:
public void ChangeValueOfXlsxCell(Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl editorControl)
{
    // get visual editor for spreadsheet document
    Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor spreadsheetVisualEditor = editorControl.VisualEditor;

    // get value or formula of focused cell
    string cellValue = spreadsheetVisualEditor.FocusedCellValue;

    // set value or formula of focused cell
    spreadsheetVisualEditor.FocusedCellValue = "0";
}
Public Sub ChangeValueOfXlsxCell(editorControl As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl)
    ' get visual editor for spreadsheet document
    Dim spreadsheetVisualEditor As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor = editorControl.VisualEditor

    ' get value or formula of focused cell
    Dim cellValue As String = spreadsheetVisualEditor.FocusedCellValue

    ' set value or formula of focused cell
    spreadsheetVisualEditor.FocusedCellValue = "0"
End Sub


Edit the formula of the focused cell using mouse and keyboard

You can edit the formula of the focused cell using textbox in formula panel (external editor) or using textbox in cell region (internal editor).

If you want to create the formula that references another cell, you should do the following steps:
If you want to create the formula that uses values from several cells, you should do the following steps:
If you want to see cells, which are used in the formula, you should do the following steps:

Delete the formula of focused cell of XLSX worksheet

If you want to delete the formula of focused cell of XLSX worksheet using mouse, you should do the following steps:
Here is C#/VB.NET code that demonstrates how to delete the formula of the focused cell of XLSX worksheet:
public void ClearXlsxCell(Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl editorControl)
{
    // get visual editor for spreadsheet document
    Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor spreadsheetVisualEditor = editorControl.VisualEditor;

    // clear contents (value and formula) of selected cells
    spreadsheetVisualEditor.ClearCellsContents();
}
Public Sub ClearXlsxCell(editorControl As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl)
    ' get visual editor for spreadsheet document
    Dim spreadsheetVisualEditor As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor = editorControl.VisualEditor

    ' clear contents (value and formula) of selected cells
    spreadsheetVisualEditor.ClearCellsContents()
End Sub


List of supported formulas


Here is the list of supported "Date and Time" formulas:
Here is the list of supported "Engineering" formulas:
Here is the list of supported "Financial" formulas:
Here is the list of supported "Information" formulas:
Here is the list of supported "Logical" formulas:
Here is the list of supported "Lookup and Reference" formulas:
Here is the list of supported "Math and Trigonometry" formulas:
Here is the list of supported "Statistical" formulas:
Here is the list of supported "Text and Data" formulas: