[]
        
(Showing Draft Content)

GC.Spread.Sheets.Tables.TableManager

Class: TableManager

Sheets.Tables.TableManager

Table of contents

Constructors

Methods

Constructors

constructor

new TableManager(sheet)

Represents a table manager that can manage all tables in a sheet.

Parameters

Name Type Description
sheet Worksheet The worksheet.

Methods

add

add(name?, row?, column?, rowCount?, columnCount?, style?): Table

Adds a range table with a specified size to the sheet.

example

//This example adds a table.
activeSheet.tables.add("Table1", 0, 0, 3, 3, GC.Spread.Sheets.Tables.TableThemes.dark1);
activeSheet.getCell(0,0).text("Name");
activeSheet.getCell(0,1).text("Value");
activeSheet.getCell(0,2).text("T/F");
activeSheet.getCell(1,0).text("AW");
activeSheet.getCell(1,1).text("5");
activeSheet.getCell(1,2).text("T");

Parameters

Name Type Description
name? string The table name.
row? number The row index.
column? number The column index.
rowCount? number The row count of the table.
columnCount? number The column count of the table.
style? TableTheme The style of the table.

Returns

Table

The new table instance.


addFromDataSource

addFromDataSource(name, row, column, dataSource, style): Table

Adds a range table with a specified data source to the sheet.

example

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);

Parameters

Name Type Description
name string The table name.
row number The row index.
column number The column index.
dataSource Object The data source for the table.
style TableTheme The style of the table.

Returns

Table

The new table instance.


all

all(): Table[]

Gets all tables of the sheet.

Returns

Table[]

The GC.Spread.Sheets.Tables.Table array of table instances. The array is never null.


find

find(row, column): Table

Gets the table of the specified cell.

example

//This example uses the find method.
activeSheet.tables.add("Table1", 0, 0, 3, 3, GC.Spread.Sheets.Tables.TableThemes.dark1);
activeSheet.getCell(0,0).text("Name");
activeSheet.getCell(0,1).text("Value");
activeSheet.getCell(0,2).text("T/F");
activeSheet.getCell(1,0).text("AW");
activeSheet.getCell(1,1).text("5");
activeSheet.getCell(1,2).text("T");
//button click
$("#button1").click(function () {
     var table  = activeSheet.tables.find(0,0);
     activeSheet.tables.move(table, 3, 3);
});

Parameters

Name Type Description
row number The row index.
column number The column index.

Returns

Table

The table instance if the cell belongs to a table; otherwise, null.


findByName

findByName(name): Table

Gets the table with a specified name.

example

//This example finds the table by name.
var activeSheet = spread.getActiveSheet();
activeSheet.tables.add("Table1", 0, 0, 3, 3, GC.Spread.Sheets.Tables.TableThemes.dark1);
activeSheet.getCell(0,0).text("Name");
activeSheet.getCell(0,1).text("Value");
activeSheet.getCell(0,2).text("T/F");
activeSheet.getCell(1,0).text("AW");
activeSheet.getCell(1,1).text("5");
activeSheet.getCell(1,2).text("T");
// button click
$("#button1").click(function () {
     var table  = activeSheet.tables.findByName("Table1");
     alert(table);
     activeSheet.tables.move(table, 3, 3);
});

Parameters

Name Type Description
name string The table name.

Returns

Table

The table instance if the cell belongs to a table; otherwise, null.


move

move(table, row, column): void

Changes the table location.

example

var activeSheet = spread.getActiveSheet();
activeSheet.tables.add("Table1", 0, 0, 3, 3, GC.Spread.Sheets.Tables.TableThemes.dark1);
activeSheet.getCell(0,0).text("Name");
activeSheet.getCell(0,1).text("Value");
activeSheet.getCell(0,2).text("T/F");
activeSheet.getCell(1,0).text("AW");
activeSheet.getCell(1,1).text("5");
activeSheet.getCell(1,2).text("T");
// button click
$("#button1").click(function () {
     var table  = activeSheet.tables.findByName("Table1");
     alert(table);
     activeSheet.tables.move(table, 3, 3);
});

Parameters

Name Type Description
table string | Table The table instance or the table name.
row number The new row index.
column number The new column index.

Returns

void


remove

remove(table, options): Table

Removes a specified table.

example

var table  = activeSheet.tables.find(0,0);
activeSheet.tables.remove(table, GC.Spread.Sheets.Tables.TableRemoveOptions.keepData);

Parameters

Name Type Description
table Table The table instance or the table name.
options TableRemoveOptions Specifies what data is kept when removing the table.

Returns

Table


resize

resize(table, range): void

Changes the table size.

example

//This example resizes the table.
activeSheet.tables.add("Table1", 0, 0, 3, 3, GC.Spread.Sheets.Tables.TableThemes.dark1);
activeSheet.getCell(0,0).text("Name");
activeSheet.getCell(0,1).text("Value");
activeSheet.getCell(0,2).text("T/F");
activeSheet.getCell(1,0).text("AW");
activeSheet.getCell(1,1).text("5");
activeSheet.getCell(1,2).text("T");
//button click
$("#button1").click(function () {
     var table  = activeSheet.tables.find(0,0);
     activeSheet.tables.resize(table, new GC.Spread.Sheets.Range(0,0,4,4));
});

Parameters

Name Type Description
table string | Table The table or the table name.
range Range The new table range. The headers must remain in the same row, and the resulting table range must overlap the original table range.

Returns

void