OfficeExtension.LoadOption interface
指定应加载对象的哪些属性。 执行同步 () 方法时会发生此加载。 这将同步 Office 对象和相应的 JavaScript 代理对象之间的状态。
注解
对于 Word,指定属性和分页信息的首选方法是使用字符串文本。 前两个示例说明了请求段落集合中段落的文本和字体大小属性的首选方法:
context.load(paragraphs, 'text, font/size');
paragraphs.load('text, font/size');
下面是使用对象表示法(包括分页)的类似示例:
context.load(paragraphs, {select: 'text, font/size', expand: 'font', top: 50, skip: 0});
paragraphs.load({select: 'text, font/size', expand: 'font', top: 50, skip: 0});
请注意,如果我们未在 select 语句中指定字体对象的特定属性,expand 语句本身将指示需加载所有字体属性。
使用方
- Excel.AllowEditRangeCollection: load
- Excel.BindingCollection: load
- Excel.ChartCollection: load
- Excel.ChartLegendEntryCollection: load
- Excel.ChartPointsCollection: load
- Excel.ChartSeriesCollection: load
- Excel.ChartTrendlineCollection: load
- Excel.CommentCollection: load
- Excel.CommentReplyCollection: load
- Excel.ConditionalFormatCollection: load
- Excel.ConditionalRangeBorderCollection: load
- Excel.CustomPropertyCollection: load
- Excel.CustomXmlPartCollection: load
- Excel.CustomXmlPartScopedCollection: load
- Excel.DataPivotHierarchyCollection: load
- Excel.DocumentTaskChangeCollection: load
- Excel.DocumentTaskCollection: load
- Excel.FilterPivotHierarchyCollection: load
- Excel.GroupShapeCollection: load
- Excel.LinkedEntityDataDomainCollection: load
- Excel.LinkedWorkbookCollection: load
- Excel.NamedItemCollection: load
- Excel.NamedSheetViewCollection: load
- Excel.NoteCollection: load
- Excel.PageBreakCollection: load
- Excel.PaneCollection: load
- Excel.PivotFieldCollection: load
- Excel.PivotHierarchyCollection: load
- Excel.PivotItemCollection: load
- Excel.PivotTableCollection: load
- Excel.PivotTableScopedCollection: load
- Excel.PivotTableStyleCollection: load
- Excel.QueryCollection: load
- Excel.RangeAreasCollection: load
- Excel.RangeBorderCollection: load
- Excel.RangeCollection: load
- Excel.RangeViewCollection: load
- Excel.RowColumnPivotHierarchyCollection: load
- Excel.SensitivityLabelDetailsCollection: load
- Excel.SettingCollection: load
- Excel.ShapeCollection: load
- Excel.SlicerCollection: load
- Excel.SlicerItemCollection: load
- Excel.SlicerStyleCollection: load
- Excel.StyleCollection: load
- Excel.TableCollection: load
- Excel.TableColumnCollection: load
- Excel.TableRowCollection: load
- Excel.TableScopedCollection: load
- Excel.TableStyleCollection: load
- Excel.TimelineStyleCollection: load
- Excel.WindowCollection: load
- Excel.WorksheetCollection: load
- Excel.WorksheetCustomPropertyCollection: load
- OfficeExtension.ClientRequestContext: load, loadRecursive
- OneNote.InkAnalysisLineCollection: load
- OneNote.InkAnalysisParagraphCollection: load
- OneNote.InkAnalysisWordCollection: load
- OneNote.InkStrokeCollection: load
- OneNote.InkWordCollection: load
- OneNote.NotebookCollection: load
- OneNote.PageCollection: load
- OneNote.PageContentCollection: load
- OneNote.ParagraphCollection: load
- OneNote.PointCollection: load
- OneNote.SectionCollection: load
- OneNote.SectionGroupCollection: load
- OneNote.TableCellCollection: load
- OneNote.TableRowCollection: load
- PowerPoint.BindingCollection: load
- PowerPoint.CustomPropertyCollection: load
- PowerPoint.CustomXmlPartCollection: load
- PowerPoint.CustomXmlPartScopedCollection: load
- PowerPoint.HyperlinkCollection: load
- PowerPoint.HyperlinkScopedCollection: load
- PowerPoint.SensitivityLabelDetailsCollection: load
- PowerPoint.ShapeCollection: 加载
- PowerPoint.ShapeScopedCollection: load
- PowerPoint.SlideCollection: 加载
- PowerPoint.SlideLayoutCollection: load
- PowerPoint.SlideMasterCollection: load
- PowerPoint.SlideScopedCollection: load
- PowerPoint.TableCellCollection: load
- PowerPoint.TableColumnCollection: load
- PowerPoint.TableRowCollection: load
- PowerPoint.TagCollection: load
- Visio.CommentCollection: load
- Visio.HyperlinkCollection: load
- Visio.PageCollection: load
- Visio.ShapeCollection: load
- Visio.ShapeDataItemCollection: load
- Word.AnnotationCollection: load
- Word.BookmarkCollection: load
- Word.BorderCollection: load
- Word.BorderUniversalCollection: load
- Word.BreakCollection: load
- Word.CoauthorCollection: load
- Word.CoauthoringLockCollection: load
- Word.CoauthoringUpdateCollection: load
- Word.CommentCollection: load
- Word.CommentReplyCollection: load
- Word.ConflictCollection: load
- Word.ContentControlCollection: load
- Word.ContentControlListItemCollection: load
- Word.CustomPropertyCollection: load
- Word.CustomXmlNodeCollection: load
- Word.CustomXmlPartCollection: load
- Word.CustomXmlPartScopedCollection: load
- Word.CustomXmlPrefixMappingCollection: load
- Word.CustomXmlSchemaCollection: load
- Word.CustomXmlValidationErrorCollection: load
- Word.DocumentLibraryVersionCollection: load
- Word.FieldCollection: load
- Word.FrameCollection: load
- Word.HeadingStyleCollection: load
- Word.HtmlDivisionCollection: load
- Word.HyperlinkCollection: load
- Word.IndexCollection: load
- Word.InlinePictureCollection: load
- Word.ListCollection: load
- Word.ListLevelCollection: load
- Word.ListTemplateCollection: load
- Word.ListTemplateGalleryCollection: load
- Word.NoteItemCollection: load
- Word.PageCollection: load
- Word.PaneCollection: load
- Word.ParagraphCollection: 加载
- Word.RangeCollection: load
- Word.RangeScopedCollection: load
- Word.ReadabilityStatisticCollection: load
- Word.ReviewerCollection: load
- Word.RevisionCollection: load
- Word.SectionCollection: load
- Word.SensitivityLabelDetailsCollection: load
- Word.SettingCollection: load
- Word.ShapeCollection: load
- Word.SourceCollection: load
- Word.StyleCollection: load
- Word.TabStopCollection: load
- Word.TableCellCollection: load
- Word.TableCollection: load
- Word.TableColumnCollection: load
- Word.TableOfAuthoritiesCategoryCollection: load
- Word.TableOfAuthoritiesCollection: load
- Word.TableOfContentsCollection: load
- Word.TableOfFiguresCollection: load
- Word.TableRowCollection: load
- Word.TemplateCollection: load
- Word.TextColumnCollection: load
- Word.TrackedChangeCollection: load
- Word.WindowCollection: load
- Word.XmlNodeCollection: load
示例
// This example shows how to get the paragraphs in the Word document
// along with their text and font size properties.
// Run a batch operation against the Word object model.
Word.run(function (context) {
// Create a proxy object for the paragraphs collection.
const paragraphs = context.document.body.paragraphs;
// Queue a command to load the text and font properties.
// It is best practice to always specify the property set.
// Otherwise, all properties are returned on the object.
context.load(paragraphs, 'text, font/size');
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
return context.sync().then(function () {
// Insert code that works with the paragraphs loaded by context.load().
})
})
.catch(function (error) {
console.log('Error: ' + JSON.stringify(error));
if (error instanceof OfficeExtension.Error) {
console.log('Debug info: ' + JSON.stringify(error.debugInfo));
}
});
属性
| expand | 逗号分隔的字符串或字符串数组,用于指定要加载的导航属性。 |
| select | 指定要加载的属性的逗号分隔的字符串或字符串数组。 |
| skip | 仅对集合类型可用。 指定集合中要跳过且不包含在结果中的项目数。 如果指定 |
| top | 仅对集合类型可用。 指定结果中可以包含的集合项最大数量。 |
属性详细信息
expand
逗号分隔的字符串或字符串数组,用于指定要加载的导航属性。
expand?: string | string[];
属性值
string | string[]
select
指定要加载的属性的逗号分隔的字符串或字符串数组。
select?: string | string[];
属性值
string | string[]
skip
仅对集合类型可用。 指定集合中要跳过且不包含在结果中的项目数。 如果指定 top,跳过指定数目的项目后将会启动结果集。
skip?: number;
属性值
number
top
仅对集合类型可用。 指定结果中可以包含的集合项最大数量。
top?: number;
属性值
number
示例
// This OneNote example shows how to get the page title and indentation level
// of the top five pages in the current section.
OneNote.run(function (context) {
// Get the pages in the current section.
const pages = context.application.getActiveSection().pages;
// Queue a command to load the pages.
pages.load({ "select":"title,pageLevel", "top":5, "skip":0 });
return context.sync()
.then(function() {
// Iterate through the collection of pages.
$.each(pages.items, function(index, page) {
// Show some properties.
console.log("Page title: " + page.title);
console.log("Indentation level: " + page.pageLevel);
});
}).catch(function(error) {
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
})
});