Office.context.document.customXmlParts未定义 [英] Office.context.document.customXmlParts is undefined
问题描述
我正在使用Office JS处理Excel加载项,在任务窗格中,我调用Office.context.document.customXmlParts.getByNamespaceAsync,但是它引发异常"TypeError:无法读取未定义的属性" getByNamespaceAsync"(即Office) .context.document.customXmlParts未定义
office-js版本是1.0.52
以下获取customXmlParts的方法有效:
return await Excel.run(async ctx => {
const workbook = ctx.workbook;
workbook.load("customXmlParts");
await ctx.sync();
const items = workbook.customXmlParts.items;
...
}
但是我需要调用getByNamespaceAsync才能在回调中使用Office.CustomXmlPart.value.addHandlerAsync,因此上述方法不合适.
请问有什么主意吗?
这是因为Office.context.document.customXmlParts仅在word上受支持.请使用Excel.Workbook.customXmlParts代替Excel插件
I'm working on an Excel addin using Office JS, in a taskpane, I call Office.context.document.customXmlParts.getByNamespaceAsync, but it throws exception 'TypeError: Cannot read property 'getByNamespaceAsync' of undefined', namely Office.context.document.customXmlParts is undefined
The office-js version is 1.0.52
The below way to get the customXmlParts works:
return await Excel.run(async ctx => {
const workbook = ctx.workbook;
workbook.load("customXmlParts");
await ctx.sync();
const items = workbook.customXmlParts.items;
...
}
But I need to call getByNamespaceAsync to use the Office.CustomXmlPart.value.addHandlerAsync in the callback, so the above way doesn't suit.
Any idea please?
That's because Office.context.document.customXmlParts only supported on word. Pls use Excel.Workbook.customXmlParts instead for Excel Addin
这篇关于Office.context.document.customXmlParts未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!