Spread Windows Forms 14.0
Spread Windows Forms 14.0 Product Documentation / Developer's Guide / Tables / Adding a Table Formula
In This Topic
    Adding a Table Formula
    In This Topic

    You can add formulas to the table in a total row at run time with the Formula Editor or with code.

    Add a total row and then select the drop-down arrow at the bottom right corner of the table to display formulas.

    Table formula example

    You can select More Functions to display the Formula Editor as shown in the following figure.

    Formula Editor Dialog

    You can add formulas to the table with the Formula property. For more information about using structured references in table formulas, see Using Structured References.

    Using Code

    Use the TotalRowVisible property to display the total row for the table.

    Example

    This example adds a total row.

    C#
    Copy Code
    fpSpread1.Sheets[0].Cells[1, 1].Text = "Last Name";
    fpSpread1.Sheets[0].Cells[1, 2].Text = "Value";
    fpSpread1.Sheets[0].Cells[2, 1].Text = "Smith";
    fpSpread1.Sheets[0].Cells[2, 2].Value = 50;
    fpSpread1.Sheets[0].Cells[3, 1].Text = "Vil";
    fpSpread1.Sheets[0].Cells[3, 2].Value = 10;
    fpSpread1.Sheets[0].Cells[4, 1].Text = "Press";
    fpSpread1.Sheets[0].Cells[4, 2].Value = 78;
    FarPoint.Win.Spread.TableView table = fpSpread1.Sheets[0].AddTable("table", 1, 1, 5, 2);
    table.TotalRowVisible = true;
    
    VB
    Copy Code
    fpSpread1.Sheets(0).Cells(1, 1).Text = "Last Name"
    fpSpread1.Sheets(0).Cells(1, 2).Text = "Value"
    fpSpread1.Sheets(0).Cells(2, 1).Text = "Smith"
    fpSpread1.Sheets(0).Cells(2, 2).Value = 50
    fpSpread1.Sheets(0).Cells(3, 1).Text = "Vil"
    fpSpread1.Sheets(0).Cells(3, 2).Value = 10
    fpSpread1.Sheets(0).Cells(4, 1).Text = "Press"
    fpSpread1.Sheets(0).Cells(4, 2).Value = 78
    Dim table As FarPoint.Win.Spread.TableView = fpSpread1.Sheets(0).AddTable("table", 1, 1, 5, 2)
    table.TotalRowVisible = True
    
    See Also