你可以设置单元格的对齐方式和缩进。

单元格对齐有两个方向:

  1. 水平对齐(hAlign 方法),
  2. 垂直对齐(vAlign 方法)。

你可以使用 textIndent 来设置单元格内容的缩进方式。



参考代码

以下代码给 B2 单元格设置了水平方向和垂直方向的对齐方式,给 B3 单元格设置了缩进。
This example sets the vertical and horizontal alignment for cell B2 and specifies a text indent for cell B3.

JavaScript

Copy Code

// 设置水平居中和竖直居中

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");
// 设置缩进

cell = activeSheet.getCell(2, 1, GC.Spread.Sheets.SheetArea.viewport);cell.textIndent(2);cell.value("Indent");

 

更多信息
Setting Styles
Setting Text Decoration
wordWrap Method