Spread WPF 14
Spread WPF Documentation / Developer's Guide / Managing the User Interface / Creating Tables
In This Topic
    Creating Tables
    In This Topic

    You can display data in a table in the control. The table has options to filter or sort the data.

    You can use default styles for the table or create custom styles for the table or various sections of the table with the TableStyle class. The following image displays a default table style:

    Table with default style

    You can use a cell range or the DataSource property for the table data.

    The row count for the table includes the header and footer rows. Tables support frozen rows and columns, sparklines, conditional formats, and cell spans. You can cut, copy, or paste the table data.

    Tables can be exported to or imported from Excel-formatted files.

    A cell can only exist in one table.

    Using Code

    The following example uses the AddTable method to add a table to the control.

    CS
    Copy Code

    public class lname
            {
                public string last { get; set; }
                public int val { get; set; }
                public lname(string last, int val)
                {
                    this.last = last;
                    this.val = val;
                }
            }

            private void Window_Loaded(object sender, RoutedEventArgs e)
            {

    lname[] arr = new lname[] { new lname("Smith", 100), new lname("Fender", 3), new lname("Gill", 5) };
    gcSpreadSheet1.Sheets[0].AddTable("Table1", 0, 0, arr);
    gcSpreadSheet1.Invalidate();

    VB.NET
    Copy Code

    Public Class lname
     Public Property last() As String
      Get
       Return m_last
      End Get
      Set
       m_last = Value
      End Set
     End Property
     Private m_last As String
     Public Property val() As Integer
      Get
       Return m_val
      End Get
      Set
       m_val = Value
      End Set
     End Property
     Private m_val As Integer
     Public Sub New(last As String, val As Integer)
      Me.last = last
      Me.val = val
     End Sub
    End Class

    Dim arr As lname() = New lname() {New lname("Smith", 100), New lname("Fender", 3), New lname("Gill", 5)}
    GcSpreadSheet1.Sheets(0).AddTable("Table1", 0, 0, arr)
    GcSpreadSheet1.Invalidate()

    See Also