Spread Windows Forms 14.0
Spread Windows Forms 14.0 Product Documentation / Developer's Guide / Formulas in Cells / Displaying Formula in Cells
In This Topic
    Displaying Formula in Cells
    In This Topic

    Spread for WinForms allows you to display the formula in a cell instead of its final calculated value. The DisplayFormulas property in IWorksheetView interface can be used to enable or disable the display of cell formulas. By default, it is set to false. The DisplayFormulas property is set at the worksheet level. Hence, the other worksheets are not impacted by the value of any particular sheet.

    When DisplayFormulas is set to true, the column widths are doubled to display the long formulas in cells conveniently. However when set to false, the column widths are restored to their original width.

    Note: When DisplayFormulas property is enabled, text overflow and auto merge cells are disabled.

    Example

    This example code sets the DisplayFormulas property to true to display the formula in cell C1.

    C#
    Copy Code
    // Set value in Cells
    fpSpread1.ActiveSheet.Cells["A1"].Value = 10;
    fpSpread1.ActiveSheet.Cells["B1"].Value = 20;
    // Set formula in Cell
    fpSpread1.ActiveSheet.Cells["C1"].Formula = "SUM(A1, B1)";
                
    // Set DisplayFormula to true for the activeSheet
    fpSpread1.AsWorkbook().ActiveSheet.View.DisplayFormulas = true;
    

    VB
    Copy Code
    ' Set value in Cells
    fpSpread1.ActiveSheet.Cells("A1").Value = 10
    fpSpread1.ActiveSheet.Cells("B1").Value = 20
    ' Set formula in Cell
    fpSpread1.ActiveSheet.Cells("C1").Formula = "SUM(A1, B1)"
    ' Set DisplayFormula to true for the activeSheet
    fpSpread1.AsWorkbook().ActiveSheet.View.DisplayFormulas = True
    

    Using Spread Designer

    To enable 'Show Formulas' option in Spread Designer, click on the 'Show Formulas' option in Formulas tab. The "Show Formulas" button is grayed when the mode is already enabled.