SpreadJS 13
SpreadJS Documentation / Sample Code / Sample Code for Cells / Setting Alignment and Indentation
In This Topic
    Setting Alignment and Indentation
    In This Topic

    You can set the alignment and indentation in a cell.

    Cell alignment and indentation

    Using Code

    The following example sets the alignment and indents the text in the cell.

    JavaScript
    Copy Code
    window.onload = function()
    {
       var spread =
       new GC.Spread.Sheets.Workbook(document.getElementById("ss"),{sheetCount:3});
       var activeSheet = spread.getActiveSheet();
      
       // Set the horizontal and vertical alignment of string to “center”
       var cell = activeSheet.getCell(1, 1, GC.Spread.Sheets.SheetArea.viewport);
       cell.hAlign(GC.Spread.Sheets.HorizontalAlign.center);
       cell.vAlign(GC.Spread.Sheets.VerticalAlign.center);
       cell.value("Alignment");
       // Set the indent of strings.
       cell = activeSheet.getCell(2, 1, GC.Spread.Sheets.SheetArea.viewport);
       cell.textIndent(2);
       cell.value("Indent");
       activeSheet.getRange(1, -1,  2, -1, GC.Spread.Sheets.SheetArea.viewport).height(40);
       activeSheet.getRange(-1, 1, -1, 1, GC.Spread.Sheets.SheetArea.viewport).width(120);
    }
    
    See Also