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 | 指定した場合は、 = (数式) フィールド で評価する数式を指定します。
|
| number |
指定した場合、 |
プロパティの詳細
formula
指定した場合は、 = (数式) フィールド で評価する数式を指定します。
formula プロパティは、選択範囲がセル内にあり、カーソルを含むセルの上または左に値を含むセルが少なくとも 1 つ存在する場合にのみ、オプションです。 カーソルの上のセルに値が入力されている場合、挿入されたフィールドは {=SUM(ABOVE)}、カーソルの左側のセルに値が入力されている場合、挿入されたフィールドは {=SUM(LEFT)}になります。 カーソルの上のセルとその左側のセルの両方に値が含まれる場合、Microsoft Word は次のルールを使用して、挿入するSUM関数を決定します。
カーソルのすぐ上のセルに値が含まれている場合は、Word は
{=SUM(ABOVE)}を挿入します。カーソルのすぐ上のセルに値が含まれていないが、カーソルのすぐ左のセルに値が含まれている場合、Word は
{=SUM(LEFT)}を挿入します。カーソルのすぐ上のセルとそのすぐ下のセルのいずれにも値が含まれていない場合、Word は
{=SUM(ABOVE)}を挿入します。formulaプロパティを指定せずに、カーソルの上と左のセルがすべて空である場合、= (Formula)フィールドを使用するとエラーが発生します。
formula?: string;
プロパティ値
string
注釈
numberFormat
指定した場合、 = (Formula) フィールドの結果の形式を指定します。
numberFormat?: string;
プロパティ値
string