Office.context.document.customXmlParts is undefined

守給你的承諾、 提交于 2020-06-01 06:04:44

问题


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?


回答1:


That's because Office.context.document.customXmlParts only supported on word. Pls use Excel.Workbook.customXmlParts instead for Excel Addin

https://docs.microsoft.com/en-us/office/dev/add-ins/reference/requirement-sets/office-add-in-requirement-sets#customxmlparts



来源:https://stackoverflow.com/questions/61435220/office-context-document-customxmlparts-is-undefined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!