SpreadJS Documentation > Sample Code > Sample Code for Rows and Columns > Adding Columns and Rows |
You can add columns and rows.
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"); }); }); |