I’m trying to access CustomXMLParts from an Excel file.
According to this post
that mentioned it but that person only needed access to the custom document properties which is a subset of the CustomXMLParts.
Below is an example of using an Excel add-in to create a CustomXMLPart where Wb is a Microsoft.Office.Interop.Excel.Workbook:
CustomXMLPart cxp = Wb.CustomXMLParts.SelectByNamespace("http://my.namespace.com").Cast<CustomXMLPart>().FirstOrDefault();
if (cxp == null)
cxp = Wb.CustomXMLParts.Add("<MyXmlData1 xmlns=“http://my.namespace.com”/>");
Debug.WriteLine("Id: " + cxp.Id);
Debug.WriteLine("NamespaceURI: " + cxp.NamespaceURI);
Debug.WriteLine("XML: " + cxp.XML);
Debug.Assert(Wb.CustomXMLParts.SelectByNamespace(“http://my.namespace.com”).Cast<CustomXMLPart>().Any(), “Expected CustomXMLPart to be found”);
I’m attaching an Excel document that includes the XML added in the above example.
I need to be able to add, read, and update a custom xml section both within an Excel add-in and using Aspose.Cells. If the CustomXMLParts is not implemented in Aspose.Cells, what alternatives are there for storing xml within a workbook? The XML is being used to implement data bindings to an external source.