SetItalic
为文本字符设置斜体属性。
语法
expression.SetItalic(isItalic);
expression - 表示 ApiTextRange 类的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 默认值 | 描述 |
|---|---|---|---|---|
| isItalic | 必需 | boolean | null | 传递 null 可移除斜体格式。 |
返回值
示例
在工作表的形状中将范围内的文本设置为斜体。
// The formatting applies to the covered fragment only.
// Make the first word italic.
let worksheet = Api.GetActiveSheet();
let fill = Api.CreateSolidFill(Api.RGB(255, 111, 61));
let stroke = Api.CreateStroke(0, Api.CreateNoFill());
let shape = worksheet.AddShape("rect", 200 * 36000, 80 * 36000, fill, stroke, 3, 0, 1, 0);
let docContent = shape.GetContent();
let paragraph = docContent.GetElement(0);
paragraph.AddText("Hello World");
let range = shape.GetTextRange();
range.GetRange(0, 5).SetItalic(true);