SpreadJS Documentation
Getting the Cell Position and Size
SpreadJS Documentation > Sample Code > Sample Code for Cells > Getting the Cell Position and Size

You can get the location and size of specific cells.

Using Code

This example gets the cell location and size.

JavaScript
Copy Code

spread.getActiveSheet().bind(GC.Spread.Sheets.Events.CellClick, function (e, info) {
     if(info.sheetArea ===GC.Spread.Sheets.SheetArea.viewport){
         console.log("Clicked cell index (" + info.row + "," + info.col + ")");

         //Acquire the coordinate information of regular cells which exist at the specified index position
         var cellRect = spread.getActiveSheet().getCellRect(info.row, info.col);
         console.log("X coordinate:" + cellRect.x);
         console.log("Y coordinate:" + cellRect.y);
         console.log("Cell width:" + cellRect.width);
         console.log("Cell height:" + cellRect.height);
     }
 });