You can add structured references to tables using the Formula property.
A cell outside of the table can have a formula with a table reference; however, the table name must be unique among table names and custom names. The table name must also be valid.
Set the Formula property for the cell.
This example code sums the Value column in the table.
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; fpSpread1.Sheets[0].AddTable("table", 1, 1, 5, 2); fpSpread1.Sheets[0].Cells[5, 1].Formula = "SUM(table[Value])"; |
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 fpSpread1.Sheets(0).AddTable("table", 1, 1, 5, 2) fpSpread1.Sheets(0).Cells(5, 1).Formula = "SUM(table[Value])" |