Excel.NoteCollection class

ブックの一部であるノート オブジェクトのコレクションを表します。

Extends

注釈

API セット: ExcelApi 1.18

使用元

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml

// This function adds a note to the selected cell.
await Excel.run(async (context) => {
  const selectedRange = context.workbook.getSelectedRange();

  // Note that an InvalidArgument error is thrown if multiple cells are selected.
  context.workbook.notes.add(selectedRange, "The first note.");
  await context.sync();
});

プロパティ

context

オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。

items

このコレクション内に読み込まれた子アイテムを取得します。

メソッド

add(cellAddress, content)

指定されたセルに、指定された内容を含む新しいメモを追加します。

getCount()

コレクション内のノートの数を取得します。

getItem(key)

セル アドレスからメモを取得します。

getItemAt(index)

位置に基づいてコレクションからメモを取得します。

getItemOrNullObject(key)

セル アドレスからメモを取得します。 ノート オブジェクトが存在しない場合、このメソッドは isNullObject プロパティが true に設定されたオブジェクトを返します。 詳細については、「 *OrNullObject のメソッドとプロパティ」を参照してください。

load(options)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNames)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNamesAndPaths)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

toJSON()

API オブジェクトが JSON.stringify() に渡されるときに、より有用な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (次に、JSON.stringify渡されたオブジェクトの toJSON メソッドを呼び出します)。元の Excel.NoteCollection オブジェクトが API オブジェクトであるのに対し、 toJSON メソッドは、コレクションの項目から読み込まれたプロパティの浅いコピーを含む "items" 配列を含むプレーンな JavaScript オブジェクト ( Excel.Interfaces.NoteCollectionData として型指定された) を返します。

プロパティの詳細

context

オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。

context: RequestContext;

プロパティ値

items

このコレクション内に読み込まれた子アイテムを取得します。

readonly items: Excel.Note[];

プロパティ値

メソッドの詳細

add(cellAddress, content)

指定されたセルに、指定された内容を含む新しいメモを追加します。

add(cellAddress: Range | string, content: any): Excel.Note;

パラメーター

cellAddress

Excel.Range | string

メモの追加先のセル。 これは、 Range オブジェクトまたは "A1" などの文字列を指定できます。 文字列が無効な場合、または範囲が 1 つのセルではない場合、 InvalidCellAddress エラーがスローされます。

content

any

メモのテキスト。

返品

注釈

API セット: ExcelApi 1.18

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml

// This function adds a note to the selected cell.
await Excel.run(async (context) => {
  const selectedRange = context.workbook.getSelectedRange();

  // Note that an InvalidArgument error is thrown if multiple cells are selected.
  context.workbook.notes.add(selectedRange, "The first note.");
  await context.sync();
});

getCount()

コレクション内のノートの数を取得します。

getCount(): OfficeExtension.ClientResult<number>;

返品

注釈

API セット: ExcelApi 1.18

getItem(key)

セル アドレスからメモを取得します。

getItem(key: string): Excel.Note;

パラメーター

key

string

メモのセル アドレス。

返品

指定されたセル アドレスのメモ。 指定されたセル アドレスにメモがない場合は、 ItemNotFound エラーがスローされます。

注釈

API セット: ExcelApi 1.18

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml

// This function sets the note on cell A1 to visible.
await Excel.run(async (context) => {
  const sheet = context.workbook.worksheets.getItem("Notes");
  const firstNote = sheet.notes.getItem("A1");

  firstNote.load();
  await context.sync();

  firstNote.visible = true;
});

getItemAt(index)

位置に基づいてコレクションからメモを取得します。

getItemAt(index: number): Excel.Note;

パラメーター

index

number

取得するメモのインデックス値。 0 を起点とする番号になります。

返品

注釈

API セット: ExcelApi 1.18

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml

// This function changes the content in the first note.
await Excel.run(async (context) => {
  const sheet = context.workbook.worksheets.getItem("Notes");
  const note = sheet.notes.getItemAt(0);
  note.content = "Changing the content of the first note.";
  await context.sync();
});

getItemOrNullObject(key)

セル アドレスからメモを取得します。 ノート オブジェクトが存在しない場合、このメソッドは isNullObject プロパティが true に設定されたオブジェクトを返します。 詳細については、「 *OrNullObject のメソッドとプロパティ」を参照してください。

getItemOrNullObject(key: string): Excel.Note;

パラメーター

key

string

メモのセル アドレス。

返品

指定されたセル アドレスまたは null オブジェクトを含むメモ。

注釈

API セット: ExcelApi 1.18

load(options)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(options?: Excel.Interfaces.NoteCollectionLoadOptions & Excel.Interfaces.CollectionLoadOptions): Excel.NoteCollection;

パラメーター

options

Excel.Interfaces.NoteCollectionLoadOptions & Excel.Interfaces.CollectionLoadOptions

読み込むオブジェクトのプロパティのオプションを指定します。

返品

load(propertyNames)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNames?: string | string[]): Excel.NoteCollection;

パラメーター

propertyNames

string | string[]

読み込むプロパティを指定するコンマ区切りの文字列または文字列の配列。

返品

load(propertyNamesAndPaths)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNamesAndPaths?: OfficeExtension.LoadOption): Excel.NoteCollection;

パラメーター

propertyNamesAndPaths
OfficeExtension.LoadOption

propertyNamesAndPaths.select は読み込むプロパティを指定するコンマ区切りの文字列であり、 propertyNamesAndPaths.expand は読み込むナビゲーションのプロパティを指定するコンマ区切りの文字列です。

返品

toJSON()

API オブジェクトが JSON.stringify() に渡されるときに、より有用な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (次に、JSON.stringify渡されたオブジェクトの toJSON メソッドを呼び出します)。元の Excel.NoteCollection オブジェクトが API オブジェクトであるのに対し、 toJSON メソッドは、コレクションの項目から読み込まれたプロパティの浅いコピーを含む "items" 配列を含むプレーンな JavaScript オブジェクト ( Excel.Interfaces.NoteCollectionData として型指定された) を返します。

toJSON(): Excel.Interfaces.NoteCollectionData;

返品