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.
You can select More Functions to display the Formula Editor as shown in the following figure.
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.
You can use the TotalRowVisible property to display the total row for the table. The following 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 |
You can automatically fill a column with the entered formula in the table by using the AutoCreateCalculatedColumns property. This property accepts a boolean value.
C# |
Copy Code
|
---|---|
fpSpread1.Sheets[0].Cells[1, 3].Text = "Sum"; fpSpread1.Features.AutoCreateCalcuatedTableColumns = true; |
Visual Basic |
Copy Code
|
---|---|
FpSpread1.Sheets(0).Cells(1, 3).Text = "Sum" FpSpread1.Features.AutoCreateCalcuatedTableColumns = True |