Excel.NoteCollection class
ブックの一部であるノート オブジェクトのコレクションを表します。
- Extends
注釈
例
// 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(cell |
指定したセルに、指定されたコンテンツを含む新しいメモを追加します。 |
| get |
コレクション内のノートの数を取得します。 |
| get |
セル アドレスでメモを取得します。 |
| get |
コレクションの位置に基づいてメモを取得します。 |
| get |
セル アドレスでメモを取得します。 note オブジェクトが存在しない場合、このメソッドは |
| load(options) | オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| toJSON() | API オブジェクトが |
プロパティの詳細
context
オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。
context: RequestContext;
プロパティ値
items
メソッドの詳細
add(cellAddress, content)
指定したセルに、指定されたコンテンツを含む新しいメモを追加します。
add(cellAddress: Range | string, content: any): Excel.Note;
パラメーター
- cellAddress
-
Excel.Range | string
ノートを追加するセル。 これは、 Range オブジェクトまたは "A1" などの文字列です。 文字列が無効な場合、または範囲が 1 つのセルでない場合は、 InvalidCellAddress エラーがスローされます。
- content
-
any
ノートのテキスト。
戻り値
注釈
例
// 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>;
戻り値
OfficeExtension.ClientResult<number>
注釈
getItem(key)
セル アドレスでメモを取得します。
getItem(key: string): Excel.Note;
パラメーター
- key
-
string
ノートのセル アドレス。
戻り値
指定されたセル アドレスを持つメモ。 指定されたセル アドレスを持つメモがない場合は、 ItemNotFound エラーがスローされます。
注釈
例
// 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 を起点とする番号になります。
戻り値
注釈
例
// 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)
セル アドレスでメモを取得します。 note オブジェクトが存在しない場合、このメソッドは isNullObject プロパティを true に設定したオブジェクトを返します。 詳細については、「 *OrNullObject メソッドとプロパティ」を参照してください。
getItemOrNullObject(key: string): Excel.Note;
パラメーター
- key
-
string
ノートのセル アドレス。
戻り値
指定されたセル アドレスまたは null オブジェクトを含むメモ。
注釈
load(options)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(options?: Excel.Interfaces.NoteCollectionLoadOptions & Excel.Interfaces.CollectionLoadOptions): Excel.NoteCollection;
パラメーター
読み込むオブジェクトのプロパティのオプションを提供します。
戻り値
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;