OneNote.NotebookCollection class   
表示笔记本的集合。
注解
方法
| get | 获取在应用程序实例中打开的指定名称的笔记本集合。 | 
| get | 按其在集合中的 ID 或索引获取笔记本。 只读。 | 
| get | 按其在集合中的位置获取笔记本。 | 
| load(options) | 将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用  | 
| load(property | 将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用  | 
| load(property | 将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用  | 
| toJSON() | 重写 JavaScript  | 
| track() | 根据文档中的相应更改来跟踪对象,以便进行自动调整。 此调用是 context.trackedObjects.add (thisObject) 的简写。 如果跨  | 
| untrack() | 释放与此对象关联的内存(如果先前已跟踪过)。 此调用是 context.trackedObjects.remove (thisObject) 的简写。 拥有许多跟踪对象会降低主机应用程序的速度,因此请在使用完毕后释放所添加的任何对象。 在内存发布生效之前,需要调用  | 
属性详细信息
context
count
items
方法详细信息
		getByName(name)
	 
	获取在应用程序实例中打开的指定名称的笔记本集合。
getByName(name: string): OneNote.NotebookCollection;参数
- name
- 
				string 
笔记本的名称。
返回
注解
示例
await OneNote.run(async (context) => {
    // Get the notebooks that are open in the application instance and have the specified name.
    const notebooks = context.application.notebooks.getByName("Homework");
    // Queue a command to load the notebooks.
    // For best performance, request specific properties.
    notebooks.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.
    // For example: notebooks.items[0]
    if (notebooks.items.length > 0) {
        console.log("Notebook name: " + notebooks.items[0].name);
        console.log("Notebook ID: " + notebooks.items[0].id);
    }
});
		getItem(index)
	 
	按其在集合中的 ID 或索引获取笔记本。 只读。
getItem(index: number | string): OneNote.Notebook;参数
- index
- 
				number | string 
笔记本的 ID 或集合中笔记本的索引位置。
返回
注解
		getItemAt(index)
	  
	按其在集合中的位置获取笔记本。
getItemAt(index: number): OneNote.Notebook;参数
- index
- 
				number 
要检索的对象的索引值。 从零开始编制索引。
返回
注解
load(options)
将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()。
load(options?: OneNote.Interfaces.NotebookCollectionLoadOptions & OneNote.Interfaces.CollectionLoadOptions): OneNote.NotebookCollection;参数
提供要加载对象的属性的选项。
返回
		load(propertyNames)
	 
	将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()。
load(propertyNames?: string | string[]): OneNote.NotebookCollection;参数
- propertyNames
- 
				string | string[] 
逗号分隔的字符串或指定要加载的属性的字符串数组。
返回
示例
await OneNote.run(async (context) => {
    // Get the notebooks that are open in the application instance and have the specified name.
    const notebooks = context.application.notebooks.getByName("Homework");
    // Queue a command to load the notebooks.
    // For best performance, request specific properties.
    notebooks.load("id");
    // 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: notebooks.items[0]
    $.each(notebooks.items, function(index, notebook) {
        notebook.addSection("Biology");
        notebook.addSection("Spanish");
        notebook.addSection("Computer Science");
    });
    
    await context.sync();
});
		load(propertyNamesAndPaths)
	   
	将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()。
load(propertyNamesAndPaths?: OfficeExtension.LoadOption): OneNote.NotebookCollection;参数
- propertyNamesAndPaths
- OfficeExtension.LoadOption
              propertyNamesAndPaths.select 是一个逗号分隔的字符串,指定要加载的属性,是 propertyNamesAndPaths.expand 一个逗号分隔的字符串,指定要加载的导航属性。
返回
toJSON()
重写 JavaScript toJSON() 方法,以便在将 API 对象传递给 JSON.stringify()时提供更有用的输出。 
              JSON.stringify
               (,反过来,调用toJSON传递给它的 对象的 方法。) 而原始OneNote.NotebookCollection对象是 API 对象,toJSON该方法返回一个纯 JavaScript 对象, (类型为 OneNote.Interfaces.NotebookCollectionData) ,其中包含一个“items”数组,其中包含集合项中任何已加载属性的浅表副本。
toJSON(): OneNote.Interfaces.NotebookCollectionData;返回
track()
根据文档中的相应更改来跟踪对象,以便进行自动调整。 此调用是 context.trackedObjects.add (thisObject) 的简写。 如果跨 .sync 调用和“.run”批处理的顺序执行外部使用此对象,并在设置属性或调用对象方法时收到“InvalidObjectPath”错误,则需要在首次创建对象时将该对象添加到跟踪的对象集合。
track(): OneNote.NotebookCollection;返回
untrack()
释放与此对象关联的内存(如果先前已跟踪过)。 此调用是 context.trackedObjects.remove (thisObject) 的简写。 拥有许多跟踪对象会降低主机应用程序的速度,因此请在使用完毕后释放所添加的任何对象。 在内存发布生效之前,需要调用 context.sync() 。
untrack(): OneNote.NotebookCollection;