OneNote.SectionCollection class

セクションのコレクションを表します。

Extends

注釈

[ API セット: OneNoteApi 1.1 ]

プロパティ

context

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

count

コレクション内のセクションの数を取得します。 読み取り専用です。

items

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

メソッド

getByName(name)

指定した名前のセクションのコレクションを取得します。

getItem(index)

ID やコレクション内のインデックスで、セクションを取得します。 読み取り専用です。

getItemAt(index)

コレクション内での位置を基にセクションを取得します。

load(options)

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

load(propertyNames)

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

load(propertyNamesAndPaths)

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

toJSON()

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

track()

ドキュメントの環境変更に基づいて自動的に調整する目的でオブジェクトを追跡します。 この呼び出しは の短縮形です context.trackedObjects.add(thisObject)。 このオブジェクトを呼び出しで .sync 使用し、".run" バッチのシーケンシャル実行の外部で使用していて、プロパティを設定するとき、またはオブジェクトのメソッドを呼び出すときに "InvalidObjectPath" エラーが発生する場合は、オブジェクトが最初に作成されたときに、追跡対象のオブジェクト コレクションにオブジェクトを追加する必要があります。

untrack()

前に追跡されていた場合、このオブジェクトに関連付けられているメモリを解放します。 この呼び出しは の context.trackedObjects.remove(thisObject)短縮形です。 追跡対象オブジェクトが多いとホスト アプリケーションの動作が遅くなります。追加したオブジェクトが不要になったら、必ずそれを解放してください。 メモリ解放が有効になる前に を呼び出す context.sync() 必要があります。

プロパティの詳細

context

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

context: RequestContext;

プロパティ値

count

コレクション内のセクションの数を取得します。 読み取り専用です。

readonly count: number;

プロパティ値

number

注釈

[ API セット: OneNoteApi 1.1 ]

items

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

readonly items: OneNote.Section[];

プロパティ値

メソッドの詳細

getByName(name)

指定した名前のセクションのコレクションを取得します。

getByName(name: string): OneNote.SectionCollection;

パラメーター

name

string

セクションの名前。

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

await OneNote.run(async (context) => {

    // Get the sections in the current notebook.
    const sections = context.application.getActiveNotebook().sections;

    // Queue a command to load the sections.
    // For best performance, request specific properties.
    sections.load("id"); 
    
    // Get the sections with the specified name.
    const groceriesSections = sections.getByName("Groceries");
    
    // Queue a command to load the sections with the specified name.
    groceriesSections.load("id,name");

    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();

    // Iterate through the collection or access items individually by index.
    if (groceriesSections.items.length > 0) {
        console.log("Section name: " + groceriesSections.items[0].name);
        console.log("Section ID: " + groceriesSections.items[0].id);
    }
});

getItem(index)

ID やコレクション内のインデックスで、セクションを取得します。 読み取り専用です。

getItem(index: number | string): OneNote.Section;

パラメーター

index

number | string

セクションの ID、またはコレクション内のセクションのインデックスの場所です。

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

getItemAt(index)

コレクション内での位置を基にセクションを取得します。

getItemAt(index: number): OneNote.Section;

パラメーター

index

number

取得するオブジェクトのインデックス値。 0 を起点とする番号になります。

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

load(options)

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

load(options?: OneNote.Interfaces.SectionCollectionLoadOptions & OneNote.Interfaces.CollectionLoadOptions): OneNote.SectionCollection;

パラメーター

options

OneNote.Interfaces.SectionCollectionLoadOptions & OneNote.Interfaces.CollectionLoadOptions

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

戻り値

load(propertyNames)

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

load(propertyNames?: string | string[]): OneNote.SectionCollection;

パラメーター

propertyNames

string | string[]

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

戻り値

await OneNote.run(async (context) => {

    // Get the sections in the current notebook.
    const sections = context.application.getActiveNotebook().sections;

    // Queue a command to load the sections.
    // For best performance, request specific properties.
    sections.load("name"); 

    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();
            
    // Iterate through the collection or access items individually by index, for example: sections.items[0]
    $.each(sections.items, function(index, section) {
        if (section.name === "Homework") {
            section.addPage("Biology");
            section.addPage("Spanish");
            section.addPage("Computer Science");
        }
    });
    await context.sync();
});

load(propertyNamesAndPaths)

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

load(propertyNamesAndPaths?: OfficeExtension.LoadOption): OneNote.SectionCollection;

パラメーター

propertyNamesAndPaths
OfficeExtension.LoadOption

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

戻り値

toJSON()

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

toJSON(): OneNote.Interfaces.SectionCollectionData;

戻り値

track()

ドキュメントの環境変更に基づいて自動的に調整する目的でオブジェクトを追跡します。 この呼び出しは の短縮形です context.trackedObjects.add(thisObject)。 このオブジェクトを呼び出しで .sync 使用し、".run" バッチのシーケンシャル実行の外部で使用していて、プロパティを設定するとき、またはオブジェクトのメソッドを呼び出すときに "InvalidObjectPath" エラーが発生する場合は、オブジェクトが最初に作成されたときに、追跡対象のオブジェクト コレクションにオブジェクトを追加する必要があります。

track(): OneNote.SectionCollection;

戻り値

untrack()

前に追跡されていた場合、このオブジェクトに関連付けられているメモリを解放します。 この呼び出しは の context.trackedObjects.remove(thisObject)短縮形です。 追跡対象オブジェクトが多いとホスト アプリケーションの動作が遅くなります。追加したオブジェクトが不要になったら、必ずそれを解放してください。 メモリ解放が有効になる前に を呼び出す context.sync() 必要があります。

untrack(): OneNote.SectionCollection;

戻り値