Here is one way you can identify and manipulate a table without the table's name. To begin, we can set up the example table and formatting:
//This example uses the find method
//Initialize spreadsheet
window.onload = function () {
var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), {sheetCount: 1});
var activeSheet = spread.getActiveSheet();
//Table and cell values/formatting
activeSheet.setRowHeight(4, 50);
activeSheet.setColumnWidth(4, 100);
activeSheet.getCell(6,0).text("Move identified table below here:")
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");
As seen above, the table name is "Table1". However, spreadsheets can grow to become complex, and you may have many similarly-named tables. We can trigger a button-clicked event to use the tables.find function of the TableManager class. In this example, we use tables.find on one of the known cells of the table to move the entire table:
//button
var b1 = new GC.Spread.Sheets.CellTypes.Button();
activeSheet.setCellType(4,4, b1, GC.Spread.Sheets.SheetArea.viewport);
b1.text('Click here!');
//click event
spread.bind(GC.Spread.Sheets.Events.ButtonClicked, function (e, args){
if (b1 instanceof GC.Spread.Sheets.CellTypes.Button)
{
var table = activeSheet.tables.find(0,0);
activeSheet.tables.move(table, 7,0);
}
});
};
Tags:
Tye Glenz