SpreadJS Documentation
Adding Columns and Rows
SpreadJS Documentation > Sample Code > Sample Code for Rows and Columns > Adding Columns and Rows

You can add columns and rows.

Using Code

This example adds columns and rows.

JavaScript
Copy Code

window.onload = function(){
       var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"),{sheetCount:3});
       var sheet = spread.getActiveSheet();
var sheet = spread.getActiveSheet();
//Set number of rows to 3.
sheet.setRowCount(3, GC.Spread.Sheets.SheetArea.viewport);
sheet.setValue(0, 0, "Row 1", GC.Spread.Sheets.SheetArea.viewport);
sheet.setValue(1, 0, "Row 2", GC.Spread.Sheets.SheetArea.viewport);
sheet.setValue(2, 0, "Row 3", GC.Spread.Sheets.SheetArea.viewport);
sheet.setColumnWidth(0, 90.0, GC.Spread.Sheets.SheetArea.viewport);

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

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