Office js customXmlParts RRS feed

  • Question

  • Hi,

    I have tried to create customXMLParts (in Excel) with Open XML (via C#). The code runs fine and creates the customXMLPart as desired. Is there a way to check if the customXmlPart has been created as desired within the excel file (can you view the XML Part created on Excel similar to how Word shows Custom XML)? I have verified XML Maps but I do not see the customXMLPart added there.

    I read the generated excel file and parse it via Office.js Excel API and try to access the customXMLPart. The api denies existence of any customXmlPart with the given namespace in the document.

    Monday, October 28, 2019 8:32 PM

All replies

  • Hi,
    change the file extension of your Excel file from ".xlsx" to ".zip". open the zip file, you can find the customXml folder into the root of the zip file.

    show an example that reads CustomXml from Office Add-ins below.

    $("#load-custom-xml-part").click(() => tryCatch(loadCustomXmlPart));
    async function loadCustomXmlPart() {
      await (context) => {
        const contosoNamespace = "http://mynamespace/CustomProperties";
        const customXmlParts = context.workbook.customXmlParts;
        const filteredXmlParts = customXmlParts.getByNamespace(contosoNamespace);
        const numberOfPartsInNamespace = filteredXmlParts.getCount();
        await context.sync();
        if (numberOfPartsInNamespace.value == 1) {
          const onlyXmlPartInNamespace = filteredXmlParts.getOnlyItem();
          const xmlBlob = onlyXmlPartInNamespace.getXml();
          await context.sync();
    /** Default helper for invoking an action and handling errors. */
    async function tryCatch(callback) {
      try {
        await callback();
      } catch (error) {
        // Note: In a production add-in, you'd want to notify the user through your add-in's UI.

    Best Regards,
    • Proposed as answer by Brian Seekford Thursday, October 31, 2019 1:55 PM
    Tuesday, October 29, 2019 2:36 AM