[]
        
(Showing Draft Content)

Adding a Table Formula

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.

Spread WinForms displays the total row formula menu with Sum selected and additional aggregate functions available.

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

Spread WinForms opens the Formula Editor with function categories, function names, and a SUBTOTAL formula for the table.

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.

Setting Visibility of Total Row

You can use the TotalRowVisible property to display the total row for the table. The following example adds a total row.

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;
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

Automatically Create Calculated Columns

You can automatically fill a column with the entered formula in the table by using the AutoCreateCalculatedColumns property. This property accepts a boolean value.

Spread WinForms uses AutoCreateCalculatedTableColumns to fill the Sum column after users enter one row formula.

fpSpread1.Sheets[0].Cells[1, 3].Text = "Sum";

fpSpread1.Features.AutoCreateCalculatedTableColumns = true;
FpSpread1.Sheets(0).Cells(1, 3).Text = "Sum"

FpSpread1.Features.AutoCreateCalculatedTableColumns = True

See Also

Formulas in Cells

Setting Table Properties in Spread Designer

Tables

Adding a Table

Using Table Filters

Resizing a Table

Sorting a Table

Setting Table Styles

Understanding Structured References