Udostępnij za pośrednictwem


NamedRange.XPath Property (2007 System)

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.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)

Syntax

'Declaration
<BrowsableAttribute(False)> _
Public ReadOnly Property XPath As XPath
'Usage
Dim instance As NamedRange 
Dim value As XPath 

value = instance.XPath
[BrowsableAttribute(false)]
public XPath XPath { get; }
[BrowsableAttribute(false)]
public:
property XPath^ XPath {
    XPath^ get ();
}
public function get XPath () : XPath

Property Value

Type: XPath
An XPath that represents the Xpath of the element mapped to the NamedRange control.

Remarks

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.

Examples

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 Sub UseXPath()
    Dim namedRange1 As Microsoft.Office.Tools.Excel.NamedRange _
        = Me.Controls.AddNamedRange(Me.Range("A1"), _
        "namedRange1")

    Dim xmlMap1 As Excel.XmlMap = _
        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)
End Sub
private void UseXPath()
{
    Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
        this.Controls.AddNamedRange(this.Range["A1", missing],
        "namedRange1");

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

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

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

.NET Framework Security

See Also

Reference

NamedRange Class

NamedRange Members

Microsoft.Office.Tools.Excel Namespace