Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

Spread.Sheets 支持自动调整行高和列宽(AutoFit)。AutoFit 操作支持按照单元格内容的大小自适应工作表的行高和列宽。

options.autoFitType 可以让工作表进行 AutoFit 操作时是否包含行表头和列表头。

双击列标题的右侧边缘来自动调整该列的列宽。

双击行标题的底部边缘来自动调整该行的行宽。

你也可以选择多列和多行并双击选中行或者列的其中一个表头的边缘,多列和多行将会一起进行自动调整行高或列宽的操作。

AutoFit 将会对隐藏的列和行,被筛选掉的列和行,以及在视口中的列和行进行自适应操作。

当行或者列的 resizable 为 false 时,AutoFit 会失效。

你也可以使用 autoFitColumn 方法, autoFitRow 方法和 Commands 类来对行和列进行自适应大小操作。


wordWrap 为 true 时,你可以使用 Alt+Enter 来输入多行文字。


示例代码

以下代码将给列重新设置了宽度。
This example fits the width of the column to the text.


JavaScript

Copy Code

activeSheet.setValue(0, 1, "testing");activeSheet.autoFitColumn(1);

 


示例代码
以下代码给行重新设置了高度。


JavaScript

Copy Code

activeSheet.setValue(0, 1, "testing\r\nmultiple\r\nlines");activeSheet.getCell(0,1).wordWrap(true);activeSheet.autoFitRow(0);

 


另见
Workbook Method

  • No labels