Word.SelectionInsertFormulaOptions interface
表示 Selection.insertFormula 方法的选项。
注解
使用方
示例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/55-selection/insert-formula.yaml
// Inserts a SUM formula with a currency number format at the selection.
// The selection must be in a table cell.
await Word.run(async (context) => {
const options: Word.SelectionInsertFormulaOptions = {
formula: "=SUM(ABOVE)",
numberFormat: "$#,##0.00",
};
context.document.selection.insertFormula(options);
await context.sync();
console.log("Inserted =SUM(ABOVE) with currency format.");
});
属性
| formula | 如果提供,则指定希望 = (Formula) 字段 计算的数学公式。
|
| number |
如果提供,则指定字段结果 |
属性详细信息
formula
如果提供,则指定希望 = (Formula) 字段 计算的数学公式。
formula仅当所选内容位于单元格中,并且在包含插入点的单元格上方或左侧至少有一个单元格包含值时,该属性才是可选的。 如果插入点上方的单元格包含值,则插入的字段为 {=SUM(ABOVE)};如果插入点左侧的单元格包含值,则插入的字段为 {=SUM(LEFT)}。 如果插入点上方的单元格和插入点左侧的单元格都包含值,则 Microsoft Word 使用以下规则来确定要插入的SUM函数。
如果插入点正上方的单元格包含值,则 Word 将
{=SUM(ABOVE)}插入。如果紧接插入点上方的单元格不包含值,但插入点紧挨着的单元格包含值,则 Word 将
{=SUM(LEFT)}插入。如果插入点正上方的单元格和插入点正下方的单元格都不包含值,则 Word 将
{=SUM(ABOVE)}插入。如果未指定
formula属性,并且插入点上方和左侧的所有单元格均为空,则使用该= (Formula)字段会导致错误。
formula?: string;
属性值
string