Excel.RangeTextRun interface
表示单元格中共享相同字体属性的一个或多个字符的序列。 可以用作 textRuns 的属性 getCellProperties 或 textRuns 输入参数 setCellProperties。
注解
使用方
示例
// 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
字体属性 (如字体名称、字号和颜色) 应用于此文本运行。
font?: Excel.CellPropertiesFont;