您好,这个功能默认没有加入,但是有示例可以参考,请参考以下代码:
- $(document).ready(function () {
- var spread = new GC.Spread.Sheets.Workbook(document.getElementById('ss'), { sheetCount: 1 });
- // get spread object
- // var spread = GcSpread.Sheets.findControl(document.getElementById('ss'));
- var activeSheet = spread.getActiveSheet();
- activeSheet.setArray(1, 1, [[124,234,6745,84,2,75,345], [234,453,234,345,234,345,2], ["spread","js","", 12, "please", "select", "us"]])
- activeSheet.bind(GC.Spread.Sheets.Events.SelectionChanging, function (e, info) {
- var sheet = info.sheet;
- var selections = info.newSelections;
- var totalCount = 0, numCount = 0, total = 0;
- if(selections && selections.length){
- for(var i = 0; i < selections.length; i++){
- var selection = selections[i];
- for(var row = selection.row; row < selection.row + selection.rowCount; row++){
- for(var col = selection.col; col < selection.col + selection.colCount; col++){
- var value = sheet.getValue(row, col);
- if(value !== null && value !== undefined && value !== ""){
- if(isFinite(value)){
- numCount++;
- total += value;
- }
- totalCount ++;
- }
- }
- }
- }
- if(totalCount>0){
- var text = "计数:"+totalCount + (numCount > 0 ? " 平均值:" + total/numCount +" 求和:" + total : "");
- $("#sumInfo").html(text);
- }
- else{
- $("#sumInfo").html("");
- }
- }
- else{
- $("#sumInfo").html("")
- }
- });
- });
复制代码
|