ExternalConnection module

class ExternalConnection.ExternalConnection

Bases: SpireObject

Represents an external connection in an Excel workbook.

This class provides properties and methods for managing external connections to data sources, such as databases, web queries, or text files. It allows for configuring connection settings and refresh behavior.

property BackgroundRefresh: bool

Gets or sets whether data is refreshed in the background.

When True, data is refreshed asynchronously without blocking the user interface.

Returns:

True if background refresh is enabled; False otherwise.

Return type:

bool

property ConnType: ConnectionDataSourceType

Gets the type of the external connection.

Returns:

An enumeration value representing the connection type.

Return type:

ConnectionDataSourceType

property ID: str

Gets the unique identifier of the external connection.

Returns:

The unique identifier of the connection.

Return type:

str

property KeepAlive: bool

Gets or sets whether to maintain the connection open.

When True, the connection is kept open after refreshing the data.

Returns:

True if the connection is kept alive; False otherwise.

Return type:

bool

property Name: str

Gets or sets the name of the external connection.

Returns:

The name of the connection.

Return type:

str

property OdcFile: str

Gets or sets the path to the Office Data Connection (ODC) file.

Returns:

The path to the ODC file.

Return type:

str

property OnlyUseConnectionFile: bool

Gets or sets whether to use only the connection file.

When True, only the connection file is used for refreshing data, ignoring any connection information stored in the workbook.

Returns:

True if only the connection file is used; False otherwise.

Return type:

bool

property RefreshedVersion: str

Gets or sets the version of the connection when it was last refreshed.

Returns:

The version string of the connection when last refreshed.

Return type:

str

property SaveData: bool

Gets or sets whether to save the external data with the workbook.

When True, the external data is saved with the workbook, allowing offline access.

Returns:

True if external data is saved with the workbook; False otherwise.

Return type:

bool