AddLineBreak
在当前文本块位置添加换行符,并从新行开始下一个元素。
语法
expression.AddLineBreak();
expression - 表示 ApiRun 类(文本块)的变量。
参数
此方法没有任何参数。
返回值
boolean
示例
在文本运行内插入换行符,使后续文本在电子表格中从新行开始。
// How do I split text across two lines inside a shape in a spreadsheet?
// Force a paragraph of text to continue on a fresh line without creating a new paragraph in a spreadsheet.
let worksheet = Api.GetActiveSheet();
let fill = Api.CreateSolidFill(Api.RGB(255, 111, 61));
let stroke = Api.CreateStroke(0, Api.CreateNoFill());
let shape = worksheet.AddShape("flowChartOnlineStorage", 120 * 36000, 70 * 36000, fill, stroke, 0, 2 * 36000, 0, 3 * 36000);
let content = shape.GetContent();
let paragraph = content.GetElement(0);
let run = Api.CreateRun();
run.AddText("This is the text for the first line. Nothing special.");
run.AddLineBreak();
run.AddText("This is the text which starts from the beginning of the second line. ");
run.AddText("It is written in two text runs, you need a space at the end of the first run sentence to separate them.");
paragraph.AddElement(run);