Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

You can align or indent text in a cell. You can specify the vertical and horizontal alignment using the hAlign and vAlign methods. Specify the indent using the textIndent method.
Image Removed
Using Code
你可以设置单元格的对齐方式和缩进。

单元格对齐有两个方向:

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

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


Image Added
参考代码

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

JavaScript

Copy Code

//

Set the horizontal and vertical alignment to centervar

设置水平居中和竖直居中

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");
//

Indent the string.

设置缩进

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

 

See Also更多信息
Setting Styles
Setting Text Decoration
wordWrap Method