You can get the cell index when clicking on a cell.
Using Code
This example gets the cell index.
JavaScript |
Copy Code
|
var spread = new GC.Spread.Sheets.Workbook($("#ss")[0]);
var activeSheet = spread.getActiveSheet();
$("#ss").click(function (e) {
//Acquire cell index from mouse-clicked point of regular cells which are neither fixed rows/columns nor row/column headers.
var offset = $("#ss").offset();
var x = e.pageX - offset.left;
var y = e.pageY - offset.top;
var target = spread.getActiveSheet().hitTest(x, y);
if(target &&
(target.rowViewportIndex === 0 || target.rowViewportIndex === 1) &&
(target.colViewportIndex === 0 || target.colViewportIndex === 1)){
console.log("Row index of mouse-clicked cells: " + target.row);
console.log("Column index of mouse-clicked cells: " + target.col);
}
});
|