GetText
返回当前数学元素的内部文本。
语法
expression.GetText(format);
expression - 表示 ApiMath 类的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 默认值 | 描述 |
|---|---|---|---|---|
| format | 可选 | "unicode" | "latex" | "unicode" | 返回文本时所采用的格式。 |
返回值
string
示例
读取电子表格中数学公式的文本表示形式,可以是 Unicode 线性文本或 LaTeX。
// Get the formula of an equation back as plain text or as LaTeX in a spreadsheet.
// Build a fraction equation, then read it back both as unicode text and as LaTeX.
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", 60 * 36000, 35 * 36000, fill, stroke, 0, 2 * 36000, 0, 3 * 36000);
let docContent = shape.GetContent();
let paragraph = docContent.GetElement(0);
let math = Api.CreateMath("dx/dy", "unicode");
paragraph.AddElement(math);
let unicodeText = math.GetText("unicode");
let latexText = math.GetText("latex");
let paragraph2 = Api.CreateParagraph();
paragraph2.AddText("Unicode: " + unicodeText + ", LaTeX: " + latexText);
docContent.Push(paragraph2);