WorkbookBase.CustomXMLParts Property
Gets the collection of custom XML parts in the workbook.
Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)
Syntax
'Declaration
Public ReadOnly Property CustomXMLParts As CustomXMLParts
public CustomXMLParts CustomXMLParts { get; }
Property Value
Type: Microsoft.Office.Core.CustomXMLParts
A Microsoft.Office.Core.CustomXMLParts collection that contains the custom XML parts in the workbook.
Remarks
For more information about custom XML parts, see Custom XML Parts Overview.
Examples
The following code example adds employee data to the document by inserting a new Microsoft.Office.Core.CustomXMLPart in the Microsoft.Office.Core.CustomXMLParts collection. The example then retrieves employee data from the XML part and displays the employee name and hire date on Sheet1.
This example is for a document-level customization.
Private Sub AddCustomXMLPart()
Dim xmlString As String = _
"<?xml version=""1.0"" encoding=""utf-8"" ?>" _
+ "<employees>" _
+ "<employee>" _
+ "<name>Karina Leal</name>" _
+ "<hireDate>1999-04-01</hireDate>" _
+ "</employee>" _
+ "</employees>"
Dim employeeXMLPart As Office.CustomXMLPart = _
Me.CustomXMLParts.Add(xmlString)
Globals.Sheet1.Range("A1").Value2 = employeeXMLPart.SelectSingleNode( _
"/employees[1]/employee[1]/name[1]").Text
Globals.Sheet1.Range("A2").Value2 = employeeXMLPart.SelectSingleNode( _
"/employees[1]/employee[1]/hireDate[1]").Text
End Sub
private void AddCustomXMLPart()
{
string xmlString =
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>"
+ "<employees>"
+ "<employee>"
+ "<name>Karina Leal</name>"
+ "<hireDate>1999-04-01</hireDate>"
+ "</employee>"
+ "</employees>";
Office.CustomXMLPart employeeXMLPart =
this.CustomXMLParts.Add(xmlString);
Globals.Sheet1.Range["A1"].Value2 = employeeXMLPart.SelectSingleNode(
"/employees[1]/employee[1]/name[1]").Text;
Globals.Sheet1.Range["A2"].Value2 = employeeXMLPart.SelectSingleNode(
"/employees[1]/employee[1]/hireDate[1]").Text;
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.