跳到主要内容

SetWrap

指定单元格中的文字是否必须换行以适应单元格大小。

语法

expression.SetWrap(isWrap);

expression - 表示 ApiRange 类的变量。

参数

名称必需/可选数据类型默认值描述
isWrap必需boolean指定单元格中的文字是否换行以适应单元格大小。

返回值

boolean

示例

在电子表格中将单元格内的文本换行以适应列宽。

// How do I stop text from spilling out of a cell in a spreadsheet?

// Enable word wrap on a cell to keep long content visible without widening the column in a spreadsheet.

let worksheet = Api.GetActiveSheet();
let range = worksheet.GetRange("A1");
range.SetValue("This is the text wrapped to fit the cell size.");
range.SetWrap(true);
worksheet.GetRange("A3").SetValue("The text in the cell A1 is wrapped: " + range.GetWrapText());