Spread.Sheets Documentation
Spanning or Merging Header Cells
Spread.Sheets Documentation > Sample Code > Sample Code for Rows and Columns > Spanning or Merging Header Cells

You can span or merge cells in the headers.

Using Code

The following code spans cells in the headers.

JavaScript
Copy Code
$(document).ready(function () {
    var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"),{sheetCount:3});
    var activeSheet = spread.getActiveSheet();

    //Set the row count of column header to 3.
    activeSheet.setRowCount(3, GC.Spread.Sheets.SheetArea.colHeader);

    //Span three columns with the origin at column header cell (0,0).
    activeSheet.addSpan(0, 0, 1, 3, GC.Spread.Sheets.SheetArea.colHeader);
    //Merge two rows having origin at column header cell(1,0).
    activeSheet.addSpan(1, 0, 2, 1, GC.Spread.Sheets.SheetArea.colHeader);

    //Set strings to the merged cells.
    activeSheet.setValue(0, 0, "Combined Columns", GC.Spread.Sheets.SheetArea.colHeader);
    activeSheet.setValue(1, 0, "Combined Rows", GC.Spread.Sheets.SheetArea.colHeader);

    //Set number of columns of row header to 2.
    activeSheet.setColumnCount(2, GC.Spread.Sheets.SheetArea.rowHeader);

    //Merge two columns and two rows with the origin at row header cell (1,0).
    activeSheet.addSpan(1, 0, 2, 2, GC.Spread.Sheets.SheetArea.rowHeader);

    //Set strings to those merged cells.
    activeSheet.setValue(1, 0, "Combined rows and columns", GC.Spread.Sheets.SheetArea.rowHeader);
});
See Also

Developer's Guide