SpreadJS Documentation
Adding Columns and Rows

You can add columns and rows.

Using Code

This example adds columns and rows.

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

    //Set number of rows to 3.
    sheet.setRowCount(3, GcSpread.Sheets.SheetArea.viewport);
    sheet.setValue(0, 0, "Row 1", GcSpread.Sheets.SheetArea.viewport);
    sheet.setValue(1, 0, "Row 2", GcSpread.Sheets.SheetArea.viewport);
    sheet.setValue(2, 0, "Row 3", GcSpread.Sheets.SheetArea.viewport);
    sheet.setColumnWidth(0, 90.0, GcSpread.Sheets.SheetArea.viewport);

    $("#button1").click(function(){
        //Add one row to Row 2.
        var sheet = $("#ss").data("spread").getActiveSheet();
        sheet.addRows(1, 1);
        sheet.setValue(1, 0, "Added row");
    });

    $("#button2").click(function(){
        //Add one row to Row 2.
        var sheet = $("#ss").data("spread").getActiveSheet();
        sheet.addColumns(1, 1);
        sheet.setValue(0, 1, "Added column");
    });
});

 

 


Copyright © GrapeCity, inc. All rights reserved.

Send comments on this topic.