Expand Minimize

NamedRange.XPath Property

Gets an XPath that represents the Xpath of the element mapped to the NamedRange control.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)

XPath XPath { get; }

Property Value

Type: Microsoft.Office.Interop.Excel.XPath
An XPath that represents the Xpath of the element mapped to the NamedRange control.

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 maps an XmlMap to the current workbook, and then sets the XPath property of a NamedRange to an XPath defined in the XmlMap. This example assumes that an Excel Schema Definition file named Customers.xsd that contains the XPath definition "/ns1:Customer/ns1:LastName" exists at the root of the C directory.

This example is for a document-level customization.

private void UseXPath()
{
    Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
        this.Controls.AddNamedRange(this.Range["A1"],
        "namedRange1");

    Excel.XmlMap xmlMap1 = Globals.ThisWorkbook.XmlMaps.Add(
        @"C:\Customers.xsd", "Customer");

    namedRange1.XPath.SetValue(xmlMap1,
        "/ns1:Customer/ns1:LastName", false);

    MessageBox.Show("The XPath of the NamedRange is: " +
        namedRange1.XPath.Value);
}

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft