Connection Connection Connection Class

Definition

Connection. When the object is serialized out as xml, its qualified name is x:connection.

[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Spreadsheet.DatabaseProperties))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Spreadsheet.OlapProperties))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Spreadsheet.WebQueryProperties))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Spreadsheet.TextProperties))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Spreadsheet.Parameters))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Spreadsheet.ConnectionExtensionList))]
public class Connection : DocumentFormat.OpenXml.OpenXmlCompositeElement
type Connection = class
    inherit OpenXmlCompositeElement
Public Class Connection
Inherits OpenXmlCompositeElement
Inheritance
Attributes

Remarks

[ISO/IEC 29500-1 1st Edition]

connection (Connection)

This element contains both the definition of how to get at an external data source as well as information describing how the connection is used within the workbook. Specific constructs in a worksheet, such as OLAP formulas, QueryTables, or PivotTables make use of information in the connection to retrieve or refresh data based on default events or the user's explicit request.

Parent Elements
connections (§18.13.2)
Child Elements Subclause
dbPr (Database Properties) §18.13.3
extLst (Future Feature Data Storage Area) §18.2.10
olapPr (OLAP Properties) §18.13.5
parameters (Query Parameters) §18.13.7
textPr (Text Import Settings) §18.13.12
webPr (Web Query Properties) §18.13.13
Attributes Description
background (Background Refresh) Indicates whether the connection can be refreshed in the background (asynchronously). true if preferred usage of the connection is to refresh asynchronously in the background; false if preferred usage of the connection is to refresh synchronously in the foreground.

This flag should be intentionally ignored in specific cases.

[Example: An example of when the flag would be ignored is in the case of a connection to OLAP data on Microsoft SQL Server Analysis Services, where the connection is used by both a PivotTable and also by CUBE functions within the workbook. That connection will always be refreshed synchronously by the PivotTable and will always be refreshed asynchronously by the CUBE functions. end example]

The possible values for this attribute are defined by the W3C XML Schema boolean datatype.
credentials (Reconnection Method) Specifies the authentication method to be used when establishing (or re-establishing) the connection.

The possible values for this attribute are defined by the ST_CredMethod simple type (§18.18.16).
deleted (Deleted Connection) Indicates whether the associated workbook connection has been deleted. true if the connection has been deleted; otherwise, false.

Deleted connections contain only the attributes name and deleted=true, all other information is removed from the SpreadsheetML file.

If a new connection is created with the same name as a deleted connection, then the deleted connection is overwritten by the new connection.

The possible values for this attribute are defined by the W3C XML Schema boolean datatype.
description (Connection Description) Specifies the user description for this connection.

The possible values for this attribute are defined by the ST_Xstring simple type (§22.9.2.19).
id (Connection Id) Specifies The unique identifier of this connection.

The possible values for this attribute are defined by the W3C XML Schema unsignedInt datatype.
interval (Automatic Refresh Interval) Specifies the number of minutes between automatic refreshes of the connection. When this attribute is not present, the connection is not automatically refreshed.

The possible values for this attribute are defined by the W3C XML Schema unsignedInt datatype.
keepAlive (Keep Connection Open) true when the spreadsheet application should make efforts to keep the connection open. When false, the application should close the connection after retrieving the information. This corresponds to the MaintainConnection property of a PivotCache object.

The possible values for this attribute are defined by the W3C XML Schema boolean datatype.
minRefreshableVersion (Minimum Version Required for Refresh) For compatibility with legacy spreadsheet applications. This represents the minimum version # that is required to be able to correctly refresh the data connection. This attribute applies to connections that are used by a QueryTable.

The possible values for this attribute are defined by the W3C XML Schema unsignedByte datatype.
name (Connection Name) Specifies the name of the connection. Each connection shall have a unique name.

When a connection has been marked as deleted and then a new connection is added with the same name, the deleted connection is replaced with the new connection.

The possible values for this attribute are defined by the ST_Xstring simple type (§22.9.2.19).
new (New Connection) true if the connection has not been refreshed for the first time; otherwise, false. This state can happen when the user saves the file before a query has finished returning.

The possible values for this attribute are defined by the W3C XML Schema boolean datatype.
odcFile (Connection File) Specifies the full path to external connection file from which this connection was created. If a connection fails during an attempt to refresh data, and reconnectionMethod=1, then the spreadsheet application will try again using information from the external connection file instead of the connection object embedded within the workbook.

This is a benefit for data source and spreadsheetML document manageability. If the definition in the external connection file is changed (e.g., because of a database server name change), then the workbooks that made use of that connection will fail to connect with their internal connection information, and reload the new connection information from this file.

This attribute is cleared by the spreadsheet application when the user manually edits the connection definition within the workbook. Can be expressed in or system-specific file path notation.

[Note: Applications can decide what forms of they support, and whether system-specific file path notations are supported. end note]

The possible values for this attribute are defined by the ST_Xstring simple type (§22.9.2.19).
onlyUseConnectionFile (Only Use Connection File) Indicates whether the spreadsheet application should always and only use the connection information in the external connection file indicated by the odcFile attribute when the connection is refreshed.

If false, then the spreadsheet application should follow the procedure indicated by the reconnectionMethod attribute described below.

Applies only to OLE DB and ODBC connections, this attribute is ignored for other types of connections.

The possible values for this attribute are defined by the W3C XML Schema boolean datatype.
reconnectionMethod (Reconnection Method) Specifies what the spreadsheet application should do when a connection fails.

The values are as follows:

1 = As required: On refresh use the existing connection information. If the existing information cannot be used to establish a connection, get updated connection information, if available from the external connection file.

2 = Always: On every refresh get updated connection information from the external connection file, if available, and use that instead of the existing connection information. In this case the data refresh will fail if the external connection file is unavailable.

3 = Never: Never get updated connection information from the external connection file even if it is available and even if the existing connection information cannot be used.

The possible values for this attribute are defined by the W3C XML Schema unsignedInt datatype.
refreshedVersion (Last Refresh Version) For backward compatibility purposes, this attribute indicates the version of the spreadsheet application that last refreshed the connection.

This attribute applies to connections that are used by a query table.

The possible values for this attribute are defined by the W3C XML Schema unsignedByte datatype.
refreshOnLoad (Refresh on Open) true if this connection should be refreshed when opening the file; otherwise, false.

The possible values for this attribute are defined by the W3C XML Schema boolean datatype.
saveData (Save Data) true if the external data fetched over the connection to populate a table is to be saved with the workbook; otherwise, false.

This exists for data security purposes - if no external data is saved in (or "cached") in the workbook, then current user credentials can be required every time to retrieve the relevant data, and people won't see the data the workbook author had last been using before saving the file.

The possible values for this attribute are defined by the W3C XML Schema boolean datatype.
savePassword (Save Password) true if the password is to be saved as part of the connection string; otherwise, False.

The possible values for this attribute are defined by the W3C XML Schema boolean datatype.
singleSignOnId (SSO Id) Identifier for Single Sign On (SSO) used for authentication between an intermediate spreadsheetML server and the external data source.

[Note: Data connectivity can use a number of different technologies. One example of potential values stored in this attribute can be found at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/spptsdk/html/cSSOReturnCodes_SV01001109.asp end note]

The possible values for this attribute are defined by the ST_Xstring simple type (§22.9.2.19).
sourceFile (Source Database File) Used when the external data source is file-based. When a connection to such a data source fails, the spreadsheet application attempts to connect directly to this file. Can be expressed in or system-specific file path notation.

[Note: Applications can decide what forms of they support, and whether system-specific file path notations are supported. end note]

The possible values for this attribute are defined by the ST_Xstring simple type (§22.9.2.19).
type (Database Source Type) Specifies the data source type.

Values are as follows:

1. ODBC-based source

2. DAO-based source

3. File based database source

4. Web query

5. OLE DB-based source

6. Text-based source

7. record set

8. DSP

The possible values for this attribute are defined by the W3C XML Schema unsignedInt datatype.

[Note: The W3C XML Schema definition of this element’s content model (CT_Connection) is located in §A.2. end note]

� ISO/IEC29500: 2008.

Constructors

Connection() Connection() Connection()

Initializes a new instance of the Connection class.

Connection(IEnumerable<OpenXmlElement>) Connection(IEnumerable<OpenXmlElement>) Connection(IEnumerable<OpenXmlElement>)

Initializes a new instance of the Connection class with the specified child elements.

Connection(OpenXmlElement[]) Connection(OpenXmlElement[]) Connection(OpenXmlElement[])

Initializes a new instance of the Connection class with the specified child elements.

Connection(String) Connection(String) Connection(String)

Initializes a new instance of the Connection class from outer XML.

Properties

Background Background Background

background.Represents the following attribute in the schema: background

ChildElements ChildElements ChildElements

Gets all the child nodes of the current element.

(Inherited from OpenXmlElement)
ConnectionExtensionList ConnectionExtensionList ConnectionExtensionList

ConnectionExtensionList. Represents the following element tag in the schema: x:extLst

ConnectionFile ConnectionFile ConnectionFile

odcFile.Represents the following attribute in the schema: odcFile

Credentials Credentials Credentials

credentials.Represents the following attribute in the schema: credentials

DatabaseProperties DatabaseProperties DatabaseProperties

DatabaseProperties. Represents the following element tag in the schema: x:dbPr

Deleted Deleted Deleted

deleted.Represents the following attribute in the schema: deleted

Description Description Description

description.Represents the following attribute in the schema: description

ExtendedAttributes ExtendedAttributes ExtendedAttributes

Gets all extended attributes (attributes not defined in the schema) of the current element.

(Inherited from OpenXmlElement)
FirstChild FirstChild FirstChild

Gets the first child of the current OpenXmlElement element.

(Inherited from OpenXmlCompositeElement)
HasAttributes HasAttributes HasAttributes

Gets a boolean value that indicates whether the current element has any attributes.

(Inherited from OpenXmlElement)
HasChildren HasChildren HasChildren

Gets a value that indicates whether the current element has any child elements.

(Inherited from OpenXmlCompositeElement)
Id Id Id

id.Represents the following attribute in the schema: id

InnerText InnerText InnerText

Gets or sets the concatenated values of the current node and all of its children.

(Inherited from OpenXmlCompositeElement)
InnerXml InnerXml InnerXml

Gets or sets the markup that represents only the child nodes of the current node.

(Inherited from OpenXmlCompositeElement)
Interval Interval Interval

interval.Represents the following attribute in the schema: interval

KeepAlive KeepAlive KeepAlive

keepAlive.Represents the following attribute in the schema: keepAlive

LastChild LastChild LastChild

Gets the last child of the current OpenXmlElement element. Returns null (Nothing in Visual Basic) if there is no such OpenXmlElement element.

(Inherited from OpenXmlCompositeElement)
LocalName LocalName LocalName

Gets the local name of the element.

MCAttributes MCAttributes MCAttributes

Sets the markup compatibility attributes. Returns null if no markup compatibility attributes are defined for the current element.

(Inherited from OpenXmlElement)
MinRefreshableVersion MinRefreshableVersion MinRefreshableVersion

minRefreshableVersion.Represents the following attribute in the schema: minRefreshableVersion

Name Name Name

name.Represents the following attribute in the schema: name

NamespaceDeclarations NamespaceDeclarations NamespaceDeclarations

Gets all the namespace declarations defined in the current element. Returns an empty enumerator if there is no namespace declaration.

(Inherited from OpenXmlElement)
NamespaceUri NamespaceUri NamespaceUri

Gets the namespace URI of the current element.

(Inherited from OpenXmlElement)
New New New

new.Represents the following attribute in the schema: new

OlapProperties OlapProperties OlapProperties

OlapProperties. Represents the following element tag in the schema: x:olapPr

OnlyUseConnectionFile OnlyUseConnectionFile OnlyUseConnectionFile

onlyUseConnectionFile.Represents the following attribute in the schema: onlyUseConnectionFile

OpenXmlElementContext OpenXmlElementContext OpenXmlElementContext

Gets the OpenXmlEementContext of the current element.

(Inherited from OpenXmlElement)
OuterXml OuterXml OuterXml

Gets the markup that represents the current element and all of its child elements.

(Inherited from OpenXmlElement)
Parameters Parameters Parameters

Parameters. Represents the following element tag in the schema: x:parameters

Parent Parent Parent

Gets the parent element of the current element.

(Inherited from OpenXmlElement)
Prefix Prefix Prefix

Gets the namespace prefix of current element.

(Inherited from OpenXmlElement)
ReconnectionMethod ReconnectionMethod ReconnectionMethod

reconnectionMethod.Represents the following attribute in the schema: reconnectionMethod

RefreshedVersion RefreshedVersion RefreshedVersion

refreshedVersion.Represents the following attribute in the schema: refreshedVersion

RefreshOnLoad RefreshOnLoad RefreshOnLoad

refreshOnLoad.Represents the following attribute in the schema: refreshOnLoad

SaveData SaveData SaveData

saveData.Represents the following attribute in the schema: saveData

SavePassword SavePassword SavePassword

savePassword.Represents the following attribute in the schema: savePassword

SingleSignOnId SingleSignOnId SingleSignOnId

singleSignOnId.Represents the following attribute in the schema: singleSignOnId

SourceFile SourceFile SourceFile

sourceFile.Represents the following attribute in the schema: sourceFile

TextProperties TextProperties TextProperties

TextProperties. Represents the following element tag in the schema: x:textPr

Type Type Type

type.Represents the following attribute in the schema: type

WebQueryProperties WebQueryProperties WebQueryProperties

WebQueryProperties. Represents the following element tag in the schema: x:webPr

XmlQualifiedName XmlQualifiedName XmlQualifiedName

Gets the qualified name of the current element.

(Inherited from OpenXmlElement)
XName XName XName

Gets the qualified name of the current element.

(Inherited from OpenXmlElement)

Methods

AddAnnotation(Object) AddAnnotation(Object) AddAnnotation(Object)

Adds an object to the current OpenXmlElement element's list of annotations.

(Inherited from OpenXmlElement)
AddNamespaceDeclaration(String, String) AddNamespaceDeclaration(String, String) AddNamespaceDeclaration(String, String)

Adds a namepace declaration to the current node.

(Inherited from OpenXmlElement)
Ancestors() Ancestors() Ancestors()

Enumerates all of the current element's ancestors.

(Inherited from OpenXmlElement)
Ancestors<T>() Ancestors<T>() Ancestors<T>()

Enumerates only the current element's ancestors that have the specified type.

(Inherited from OpenXmlElement)
Annotation(Type) Annotation(Type) Annotation(Type)

Get the first annotation object of the specified type from the current OpenXmlElement element.

(Inherited from OpenXmlElement)
Annotation<T>() Annotation<T>() Annotation<T>()

Get the first annotation object of the specified type from the current OpenXmlElement element.

(Inherited from OpenXmlElement)
Annotations(Type) Annotations(Type) Annotations(Type)

Gets a collection of annotations with the specified type for the current OpenXmlElement element.

(Inherited from OpenXmlElement)
Annotations<T>() Annotations<T>() Annotations<T>()

Gets a collection of annotations with the specified type for the current OpenXmlElement element.

(Inherited from OpenXmlElement)
Append(IEnumerable<OpenXmlElement>) Append(IEnumerable<OpenXmlElement>) Append(IEnumerable<OpenXmlElement>)

Appends each element from a list of elements to the end of the current element's list of child elements.

(Inherited from OpenXmlElement)
Append(OpenXmlElement[]) Append(OpenXmlElement[]) Append(OpenXmlElement[])

Appends each element from an array of elements to the end of the current element's list of child elements.

(Inherited from OpenXmlElement)
AppendChild<T>(T) AppendChild<T>(T) AppendChild<T>(T)

Appends the specified element to the end of the current element's list of child nodes.

(Inherited from OpenXmlCompositeElement)
ClearAllAttributes() ClearAllAttributes() ClearAllAttributes()

Clears all of the attributes, including both known attributes and extended attributes.

(Inherited from OpenXmlElement)
Clone() Clone() Clone()

Creates a duplicate of the current node.

(Inherited from OpenXmlElement)
CloneNode(Boolean) CloneNode(Boolean) CloneNode(Boolean)

Creates a duplicate of this node.

Descendants() Descendants() Descendants()

Enumerates all of the current element's descendants.

(Inherited from OpenXmlElement)
Descendants<T>() Descendants<T>() Descendants<T>()

Enumerate all of the current element's descendants of type T.

(Inherited from OpenXmlElement)
Elements() Elements() Elements()

Enumerates all of the current element's children.

(Inherited from OpenXmlElement)
Elements<T>() Elements<T>() Elements<T>()

Enumerates only the current element's children that have the specified type.

(Inherited from OpenXmlElement)
ElementsAfter() ElementsAfter() ElementsAfter()

Enumerates all of the sibling elements that follow the current element and have the same parent as the current element.

(Inherited from OpenXmlElement)
ElementsBefore() ElementsBefore() ElementsBefore()

Enumerates all of the sibling elements that precede the current element and have the same parent as the current element.

(Inherited from OpenXmlElement)
GetAttribute(String, String) GetAttribute(String, String) GetAttribute(String, String)

Gets an Open XML attribute with the specified tag name and namespace URI.

(Inherited from OpenXmlElement)
GetAttributes() GetAttributes() GetAttributes()

Gets a list that contains a copy of all the attributes.

(Inherited from OpenXmlElement)
GetEnumerator() GetEnumerator() GetEnumerator()

Returns an enumerator that iterates through the child collection.

(Inherited from OpenXmlElement)
GetFirstChild<T>() GetFirstChild<T>() GetFirstChild<T>()

Finds the first child element in type T.

(Inherited from OpenXmlElement)
InsertAfter<T>(T, OpenXmlElement) InsertAfter<T>(T, OpenXmlElement) InsertAfter<T>(T, OpenXmlElement)

Inserts the specified element immediately after the specified reference element.

(Inherited from OpenXmlCompositeElement)
InsertAfterSelf<T>(T) InsertAfterSelf<T>(T) InsertAfterSelf<T>(T)

Inserts the specified element immediately after the current element.

(Inherited from OpenXmlElement)
InsertAt<T>(T, Int32) InsertAt<T>(T, Int32) InsertAt<T>(T, Int32)

Inserts the specified element at the specified index of the current element's children.

(Inherited from OpenXmlCompositeElement)
InsertBefore<T>(T, OpenXmlElement) InsertBefore<T>(T, OpenXmlElement) InsertBefore<T>(T, OpenXmlElement)

Inserts the specified element immediately before the specified reference element.

(Inherited from OpenXmlCompositeElement)
InsertBeforeSelf<T>(T) InsertBeforeSelf<T>(T) InsertBeforeSelf<T>(T)

Inserts the specified element immediately before the current element.

(Inherited from OpenXmlElement)
IsAfter(OpenXmlElement) IsAfter(OpenXmlElement) IsAfter(OpenXmlElement)

Determines if the current element appears after a specified element in document order.

(Inherited from OpenXmlElement)
IsBefore(OpenXmlElement) IsBefore(OpenXmlElement) IsBefore(OpenXmlElement)

Determines if the current element appears before a specified element in document order.

(Inherited from OpenXmlElement)
LookupNamespace(String) LookupNamespace(String) LookupNamespace(String)

Resolves the namespace prefix in the context of the current node.

(Inherited from OpenXmlElement)
LookupPrefix(String) LookupPrefix(String) LookupPrefix(String)

Finds the corresponding prefix for a namespace uri in the current element scope.

(Inherited from OpenXmlElement)
NextSibling() NextSibling() NextSibling()

Gets the OpenXmlElement element that immediately follows the current OpenXmlElement element. Returns null (Nothing in Visual Basic) if there is no next OpenXmlElement element.

(Inherited from OpenXmlElement)
NextSibling<T>() NextSibling<T>() NextSibling<T>()

Gets the OpenXmlElement element with the specified type that follows the current OpenXmlElement element. Returns null (Nothing in Visual Basic) if there is no next OpenXmlElement.

(Inherited from OpenXmlElement)
PrependChild<T>(T) PrependChild<T>(T) PrependChild<T>(T)

Inserts the specified element at the beginning of the current element's list of child nodes.

(Inherited from OpenXmlCompositeElement)
PreviousSibling() PreviousSibling() PreviousSibling()

Gets the OpenXmlElement element that immediately precedes the current OpenXmlElement element. Returns null (Nothing in Visual Basic ) if there is no preceding OpenXmlElement element.

(Inherited from OpenXmlElement)
PreviousSibling<T>() PreviousSibling<T>() PreviousSibling<T>()

Gets the OpenXmlElement element with the specified type that precedes the current OpenXmlElement. Returns null (Nothing in Visual Basic) if there is no preceding OpenXmlElement element.

(Inherited from OpenXmlElement)
Remove() Remove() Remove()

Removes the current element from its parent.

(Inherited from OpenXmlElement)
RemoveAllChildren() RemoveAllChildren() RemoveAllChildren()

Removes all of the current element's child elements.

(Inherited from OpenXmlCompositeElement)
RemoveAllChildren<T>() RemoveAllChildren<T>() RemoveAllChildren<T>()

Remove all of the current element's child elements that are of type T.

(Inherited from OpenXmlElement)
RemoveAnnotations(Type) RemoveAnnotations(Type) RemoveAnnotations(Type)

Removes the annotations of the specified type from the current OpenXmlElement element.

(Inherited from OpenXmlElement)
RemoveAnnotations<T>() RemoveAnnotations<T>() RemoveAnnotations<T>()

Removes the annotations with the specified type from the current OpenXmlElement element.

(Inherited from OpenXmlElement)
RemoveAttribute(String, String) RemoveAttribute(String, String) RemoveAttribute(String, String)

Removes the attribute from the current element.

(Inherited from OpenXmlElement)
RemoveChild<T>(T) RemoveChild<T>(T) RemoveChild<T>(T)

Removes the specified child element.

(Inherited from OpenXmlCompositeElement)
RemoveNamespaceDeclaration(String) RemoveNamespaceDeclaration(String) RemoveNamespaceDeclaration(String)

Removes the namespace declaration for the specified prefix. Removes nothing if there is no prefix.

(Inherited from OpenXmlElement)
ReplaceChild<T>(OpenXmlElement, T) ReplaceChild<T>(OpenXmlElement, T) ReplaceChild<T>(OpenXmlElement, T)

Replaces one of the current element's child elements with another OpenXmlElement element.

(Inherited from OpenXmlCompositeElement)
SetAttribute(OpenXmlAttribute) SetAttribute(OpenXmlAttribute) SetAttribute(OpenXmlAttribute)

Sets an attribute to the specified element. If the attribute is a known attribute, the value of the attribute is set. If the attribute is an extended attribute, the 'openxmlAttribute' is added to the extended attributes list.

(Inherited from OpenXmlElement)
SetAttributes(IEnumerable<OpenXmlAttribute>) SetAttributes(IEnumerable<OpenXmlAttribute>) SetAttributes(IEnumerable<OpenXmlAttribute>)

Sets a number of attributes to the element. If an attribute is a known attribute, the value of the attribute is set. If an attribute is an extended attribute, the 'openxmlAttribute' is added to the extended attributes list.

(Inherited from OpenXmlElement)
WriteTo(XmlWriter) WriteTo(XmlWriter) WriteTo(XmlWriter)

Saves the current node to the specified XmlWriter.

(Inherited from OpenXmlElement)

Explicit Interface Implementations

IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() Inherited from OpenXmlElement

Applies to