Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Workbook.XmlNamespaces Property

Gets an Microsoft.Office.Interop.Excel.XmlNamespaces collection that represents the XML namespaces contained in the workbook.

Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel (in microsoft.office.tools.excel.dll)

public virtual XmlNamespaces XmlNamespaces { get; }

Property Value

An Microsoft.Office.Interop.Excel.XmlNamespaces collection that represents the XML namespaces contained in the workbook.

XML features, except for saving files in the XML Spreadsheet format, are available only in Microsoft Office Professional Edition 2003 and Microsoft Office Excel 2003.

The following code example uses the XmlNamespaces property to write the Uniform Resource Identifier (URI) for each XmlNamespace in the workbook to column A of worksheet Sheet1.

private void DisplayXmlNamespaceURI()
{
    if (this.XmlNamespaces.Count == 0)
    {
        MessageBox.Show("The current workbook does not have " +
            "any XML namespaces.");
    }
    else
    {
        for (int i = 0; i < this.XmlNamespaces.Count; i++)
        {
            Globals.Sheet1.Range["A" + i, missing].Value2 =
                (this.XmlNamespaces[i].Uri);
        }
    }
}

Show:
© 2015 Microsoft