SpreadJS Documentation
GC.Spread.Sheets.Tables Namespace / TableManager type / addFromDataSource Method
The table name.
The row index.
The column index.
The data source for the table.
The style of the table.
The initialization options of the table.
Whether to display a header.
boolean Whether to display a footer.
In This Topic
    addFromDataSource Method
    In This Topic
    Adds a range table with a specified data source to the sheet.
    Syntax
    var instance = new GC.Spread.Sheets.Tables.TableManager(sheet);
    var value; // Type: Table
    value = instance.addFromDataSource(name,
                                       row,
                                       column,
                                       dataSource,
                                       style,
                                       options,
                                       options.showHeader,
                                       options.showFooter);
    function addFromDataSource( 
       name : string,
       row : number,
       column : number,
       dataSource : object,
       style : TableTheme,
       options : Object,
       (optional) options.showHeader : boolean,
       (optional) options.showFooter : boolean
    ) : Table;

    Parameters

    name
    The table name.
    row
    The row index.
    column
    The column index.
    dataSource
    The data source for the table.
    style
    The style of the table.
    options
    The initialization options of the table.
    options.showHeader
    Whether to display a header.
    options.showFooter
    boolean Whether to display a footer.

    Return Value

    The new table instance.
    Example
    This example creates a table.
    var source = [
                    { LastName: "Freehafer", FirstName: "Nancy", Title: "Sales Representative", Phone: "(123)555-0100"},
                    { LastName: "Cencini", FirstName: "Andrew", Title: "Vice President, Sales", Phone: "(123)555-0101"},
                    { LastName: "Kotas", FirstName: "Jan", Title: "Sales Representative", Phone: "(123)555-0102"},
                    { LastName: "Sergienko", FirstName: "Mariya", Title: "Sales Representative", Phone: "(123)555-0103"},
                ];
                
                activeSheet.tables.addFromDataSource("Table1", 5, 2, source, GC.Spread.Sheets.Tables.TableThemes.dark1);
    See Also