Spread WPF Documentation
Using Structured References
Spread WPF Documentation > Developer's Guide > Managing the User Interface > Understanding Structured References > Using Structured References

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.

Using Code

Set the Formula property for the cell.

Example

This example code sums the Value column in the table.

C#
Copy Code
gcSpreadSheet1.Sheets[0].Cells[1, 1].Text = "Last Name";
gcSpreadSheet1.Sheets[0].Cells[1, 2].Text = "Value";
gcSpreadSheet1.Sheets[0].Cells[2, 1].Text = "Smith";
gcSpreadSheet1.Sheets[0].Cells[2, 2].Value = 50;
gcSpreadSheet1.Sheets[0].Cells[3, 1].Text = "Vil";
gcSpreadSheet1.Sheets[0].Cells[3, 2].Value = 10;
gcSpreadSheet1.Sheets[0].Cells[4, 1].Text = "Press";
gcSpreadSheet1.Sheets[0].Cells[4, 2].Value = 78;
gcSpreadSheet1.Sheets[0].AddTable("table", 1, 1, 5, 2);
gcSpreadSheet1.Sheets[0].Cells[5, 1].Formula = "SUM(table[Value])";
VB
Copy Code
gcSpreadSheet1.Sheets(0).Cells(1, 1).Text = "Last Name"
gcSpreadSheet1.Sheets(0).Cells(1, 2).Text = "Value"
gcSpreadSheet1.Sheets(0).Cells(2, 1).Text = "Smith"
gcSpreadSheet1.Sheets(0).Cells(2, 2).Value = 50
gcSpreadSheet1.Sheets(0).Cells(3, 1).Text = "Vil"
gcSpreadSheet1.Sheets(0).Cells(3, 2).Value = 10
gcSpreadSheet1.Sheets(0).Cells(4, 1).Text = "Press"
gcSpreadSheet1.Sheets(0).Cells(4, 2).Value = 78
gcSpreadSheet1.Sheets(0).AddTable("table", 1, 1, 5, 2)
gcSpreadSheet1.Sheets(0).Cells(5, 1).Formula = "SUM(table[Value])"