OneNote.Notebook class
OneNote ノートブックを表します。 ノートブックには、セクション グループとセクションが含まれます。
- Extends
注釈
使用元
プロパティ
| base |
このノートブックが存在するサイトの URL。 読み取り専用です。 |
| client |
ノートブックのクライアント URL。 読み取り専用です。 |
| context | オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。 |
| id | ノートブックの ID を取得します。 読み取り専用です。 |
| is |
ノートブックがユーザーによって作成されていない場合 (つまり、「セクションが正しく配置されなかった」場合) は true。 |
| name | ノートブックの名前を取得します。 |
| section |
ノートブック内のセクション グループ。 |
| sections | ノートブックのセクション。 |
メソッド
| add |
ノートブックの末尾に新しいセクションを追加します。 |
| add |
ノートブックの末尾に新しいセクション グループを追加します。 |
| get |
REST API ID を取得します。 |
| load(options) | オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| toJSON() | API オブジェクトが |
| track() | ドキュメントの環境変更に基づいて自動的に調整する目的でオブジェクトを追跡します。 この呼び出しは、 context.trackedObjects.add(thisObject) の短縮形です。 このオブジェクトを |
| untrack() | 前に追跡されていた場合、このオブジェクトに関連付けられているメモリを解放します。 この呼び出しは、 context.trackedObjects.remove(thisObject) の省略形です。 追跡対象オブジェクトが多いとホスト アプリケーションの動作が遅くなります。追加したオブジェクトが不要になったら、必ずそれを解放してください。 メモリ リリースを有効にする前に、 |
プロパティの詳細
baseUrl
clientUrl
context
オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。
context: RequestContext;
プロパティ値
id
isVirtual
ノートブックがユーザーによって作成されていない場合 (つまり、「セクションが正しく配置されなかった」場合) は true。
readonly isVirtual: boolean;
プロパティ値
boolean
注釈
name
sectionGroups
ノートブック内のセクション グループ。
readonly sectionGroups: OneNote.SectionGroupCollection;
プロパティ値
注釈
sections
ノートブックのセクション。
readonly sections: OneNote.SectionCollection;
プロパティ値
注釈
メソッドの詳細
addSection(name)
ノートブックの末尾に新しいセクションを追加します。
addSection(name: string): OneNote.Section;
パラメーター
- name
-
string
新しいセクションの名前を指定します。
返品
注釈
例
await OneNote.run(async (context) => {
// Gets the active notebook.
const notebook = context.application.getActiveNotebook();
// Queue a command to add a new section.
const section = notebook.addSection("Sample section");
// Queue a command to load the new section. This example reads the name property later.
section.load("name");
// Run the queued commands, and return a promise to indicate task completion.
await context.sync();
console.log("New section name is " + section.name);
});
addSectionGroup(name)
ノートブックの末尾に新しいセクション グループを追加します。
addSectionGroup(name: string): OneNote.SectionGroup;
パラメーター
- name
-
string
新しいセクションの名前を指定します。
返品
注釈
例
await OneNote.run(async (context) => {
// Gets the active notebook.
const notebook = context.application.getActiveNotebook();
// Queue a command to add a new section group.
const sectionGroup = notebook.addSectionGroup("Sample section group");
// Queue a command to load the new section group.
sectionGroup.load();
// Run the queued commands, and return a promise to indicate task completion.
await context.sync();
console.log("New section group name is " + sectionGroup.name);
});
getRestApiId()
REST API ID を取得します。
getRestApiId(): OfficeExtension.ClientResult<string>;
返品
OfficeExtension.ClientResult<string>
注釈
例
await OneNote.run(async (context) => {
// Get the current notebook.
const notebook = context.application.getActiveNotebook();
const restApiId = notebook.getRestApiId();
await context.sync();
console.log("The REST API ID is " + restApiId.value);
// Note that the REST API ID isn't all you need to interact with the OneNote REST API.
// This is only required for SharePoint notebooks. baseUrl will be null for OneDrive notebooks.
// For SharePoint notebooks, the notebook baseUrl should be used to talk to the OneNote REST API
// according to the OneNote Development Blog.
// https://learn.microsoft.com/archive/blogs/onenotedev/and-sharepoint-makes-three
});
load(options)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(options?: OneNote.Interfaces.NotebookLoadOptions): OneNote.Notebook;
パラメーター
読み込むオブジェクトのプロパティのオプションを指定します。
返品
load(propertyNames)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(propertyNames?: string | string[]): OneNote.Notebook;
パラメーター
- propertyNames
-
string | string[]
読み込むプロパティを指定するコンマ区切りの文字列または文字列の配列。
返品
例
await OneNote.run(async (context) => {
// Get the current notebook.
const notebook = context.application.getActiveNotebook();
// Queue a command to load the notebook.
// For best performance, request specific properties.
notebook.load('baseUrl');
// Run the queued commands, and return a promise to indicate task completion.
await context.sync();
console.log("Base url: " + notebook.baseUrl);
// This is only required for SharePoint notebooks, and will be null for OneDrive notebooks.
// This baseUrl should be used to talk to OneNote REST APIs according to the OneNote Development Blog.
// https://learn.microsoft.com/archive/blogs/onenotedev/and-sharepoint-makes-three
});
load(propertyNamesAndPaths)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(propertyNamesAndPaths?: {
select?: string;
expand?: string;
}): OneNote.Notebook;
パラメーター
- propertyNamesAndPaths
-
{ select?: string; expand?: string; }
propertyNamesAndPaths.select は読み込むプロパティを指定するコンマ区切りの文字列であり、 propertyNamesAndPaths.expand は読み込むナビゲーションのプロパティを指定するコンマ区切りの文字列です。
返品
toJSON()
API オブジェクトが JSON.stringify() に渡されるときに、より有用な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (次に、JSON.stringify渡されたオブジェクトの toJSON メソッドを呼び出します)。元の OneNote.Notebook オブジェクトが API オブジェクトであるのに対し、 toJSON メソッドは、元のオブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト ( OneNote.Interfaces.NotebookData と型指定) を返します。
toJSON(): OneNote.Interfaces.NotebookData;
返品
track()
ドキュメントの環境変更に基づいて自動的に調整する目的でオブジェクトを追跡します。 この呼び出しは、 context.trackedObjects.add(thisObject) の短縮形です。 このオブジェクトを .sync 呼び出しと ".run" バッチの連続実行の外部で使用していて、プロパティを設定したり、オブジェクトでメソッドを呼び出したりするときに "InvalidObjectPath" エラーが発生する場合は、オブジェクトが最初に作成されたときに、追跡対象のオブジェクト コレクションにオブジェクトを追加する必要があります。
track(): OneNote.Notebook;
返品
untrack()
前に追跡されていた場合、このオブジェクトに関連付けられているメモリを解放します。 この呼び出しは、 context.trackedObjects.remove(thisObject) の省略形です。 追跡対象オブジェクトが多いとホスト アプリケーションの動作が遅くなります。追加したオブジェクトが不要になったら、必ずそれを解放してください。 メモリ リリースを有効にする前に、 context.sync() を呼び出す必要があります。
untrack(): OneNote.Notebook;