SpreadJS Documentation
Getting Selected Ranges

You can get the ranges of multiple selected areas.

Using Code

This example gets the selected ranges.

JavaScript
Copy Code
$(document).ready(function () {
    var spread = new GcSpread.Sheets.Spread($("#ss").get(0),{sheetCount:3});
    var sheet = spread.getActiveSheet();
    sheet.setRowCount(5);
    sheet.setColumnCount(5);

    $("#button1").click(function(){         
        //Acquiring selection ranges
        var selectedRanges = $("#ss").data("spread").getActiveSheet().getSelections().toArray();

        for(var i = 0; i < selectedRanges.length; i++){
            console.log("---------------------------------------------");
            console.log("Using Range class");
            console.log("---------------------------------------------");
            console.log("Selected top row index: " + selectedRanges[i].row);
            console.log("Number of selected rows: " + selectedRanges[i].rowCount);
            console.log("Selected first column index: " + selectedRanges[i].col);
            console.log("Number of selected columns: " + selectedRanges[i].colCount);
        }
    });
});
See Also

Developer's Guide

 

 


Copyright © GrapeCity, inc. All rights reserved.

Send comments on this topic.