[]
• new TableManager(sheet)
表示一个可以管理工作表中所有表格的表格管理器。
| Name | Type | Description |
|---|---|---|
sheet |
Worksheet |
工作表。 |
▸ add(name?, row?, column?, rowCount?, columnCount?, style?): Table
向工作表添加一个指定大小的范围表格。
example
//此示例添加一个表格。
activeSheet.tables.add("Table1", 0, 0, 3, 3, '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");
| Name | Type | Description |
|---|---|---|
name? |
string |
表格名称。 |
row? |
number |
行索引。 |
column? |
number |
列索引。 |
rowCount? |
number |
表格的行数。 |
columnCount? |
number |
表格的列数。 |
style? |
string | TableTheme |
表格的样式。 |
新的表格实例。
▸ addFromDataSource(name, row, column, dataSource, style, options?): Table | Promise<Table>
向工作表添加一个指定数据源的范围表格。
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);
| Name | Type | Description |
|---|---|---|
name |
string |
表格名称。 |
row |
number |
行索引。 |
column |
number |
列索引。 |
dataSource |
string | Object | Table |
表格的数据源。 |
style |
TableTheme |
表格的样式。 |
options? |
ITableOptions |
表格的初始化选项。 |
新的表格实例。
▸ all(): Table[]
获取工作表中的所有表格。
Table[]
表格实例的GC.Spread.Sheets.Tables.Table数组。该数组永远不会为null。
▸ convertFromDataTable(table): Table
将绑定数据管理器表格的表格转换为常规表格。
example
var table = activeSheet.tables.find(0,0);
activeSheet.tables.convertFromDataTable(table);
| Name | Type | Description |
|---|---|---|
table |
string | Table |
表格实例或表格名称。 |
▸ convertToDataTable(table): Table
将常规表格转换为创建并绑定数据管理器表格的表格。
example
var table = activeSheet.tables.find(0,0);
activeSheet.tables.convertToDataTable(table);
| Name | Type | Description |
|---|---|---|
table |
string | Table |
表格实例或表格名称。 |
▸ find(row, column): Table
获取指定单元格所在的表格。
example
//此示例使用 find 方法。
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");
//按钮点击
$("#button1").click(function () {
var table = activeSheet.tables.find(0,0);
console.log(table.name());
});
| Name | Type | Description |
|---|---|---|
row |
number |
行索引。 |
column |
number |
列索引。 |
如果单元格属于某个表格,则返回该表格实例;否则返回 null。
▸ findByName(name): Table
获取指定名称的表格。
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");
//按钮点击
$("#button1").click(function () {
var table = activeSheet.tables.findByName("Table1");
console.log(table.name());
});
| Name | Type | Description |
|---|---|---|
name |
string |
表格名称。 |
如果找到指定名称的表格,则返回该表格实例;否则返回 null。
▸ move(table, row, column): void
更改表格位置。
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");
//按钮点击
$("#button1").click(function () {
var table = activeSheet.tables.findByName("Table1");
alert(table);
activeSheet.tables.move(table, 3, 3);
});
| Name | Type | Description |
|---|---|---|
table |
string | Table |
表格实例或表格名称。 |
row |
number |
新的行索引。 |
column |
number |
新的列索引。 |
void
▸ remove(table, options): Table
移除指定的表格。
example
var table = activeSheet.tables.find(0,0);
activeSheet.tables.remove(table, GC.Spread.Sheets.Tables.TableRemoveOptions.keepData);
| Name | Type | Description |
|---|---|---|
table |
string | Table |
表格实例或表格名称。 |
options |
TableRemoveOptions |
指定移除表格时要保留的数据。 |
▸ resize(table, range): void
更改表格大小。
example
//此示例调整表格大小。
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");
//按钮点击
$("#button1").click(function () {
var table = activeSheet.tables.find(0,0);
activeSheet.tables.resize(table, new GC.Spread.Sheets.Range(0,0,4,4));
});
| Name | Type | Description |
|---|---|---|
table |
string | Table |
表格或表格名称。 |
range |
Range |
新的表格范围。表头必须保持在相同的行,且结果表格范围必须与原始表格范围重叠。 |
void