Excel.RangeTextRun interface

表示单元格中共享相同字体属性的一个或多个字符的序列。 可以用作 textRuns 的属性 getCellPropertiestextRuns 输入参数 setCellProperties

注解

API 集:ExcelApi 1.18

使用方

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/cell-properties.yaml

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getActiveWorksheet();

    const textRunFormats: Excel.RangeTextRun[] = [
        {
            text: "Rich ",
            font: {
                bold: true,
                color: "#C00000",
                size: 14
            }
        },
        {
            text: "text",
            font: {
                color: "#4472C4",
                italic: true,
                underline: Excel.RangeUnderlineStyle.single
            }
        }
    ]
    const richTextProps: Excel.SettableCellProperties = {
        textRuns: textRunFormats
    };

    sheet.getRange("A7").setCellProperties([[richTextProps]]);
    await context.sync();
});

属性

font

字体属性 (如字体名称、字号和颜色) 应用于此文本运行。

text

此文本运行的文本。

属性详细信息

font

字体属性 (如字体名称、字号和颜色) 应用于此文本运行。

font?: Excel.CellPropertiesFont;

属性值

注解

API 集:ExcelApi 1.18

text

此文本运行的文本。

text: string;

属性值

string

注解

API 集:ExcelApi 1.18