GetDocContent
返回可以插入段落或文本块的形状内部内容。
语法
expression.GetDocContent();
expression - 表示 ApiShape 类的变量。
参数
此方法没有任何参数。
返回值
示例
打开形状的文档级内容并在电子表格中用新段落替换其文本。
// How do I rewrite the document content stored inside a shape in a spreadsheet?
// Clear all existing elements from a shape's document body and push in a fresh 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", 60 * 36000, 35 * 36000, fill, stroke, 0, 2 * 36000, 0, 3 * 36000);
let content = shape.GetDocContent();
content.RemoveAllElements();
let paragraph = Api.CreateParagraph();
paragraph.SetJc("left");
paragraph.AddText("We removed all elements from the shape and added a new paragraph inside it.");
content.Push(paragraph);