XLSX External Links and Data Connections: Find, Update or Remove Them
Audit workbook links, queries and connection files; explain stale data and privacy risks.
How External Dependencies Are Stored in an XLSX File
An .xlsx file is a ZIP archive containing multiple XML parts. External dependencies reside in two separate locations, governed by different schemas within the Office Open XML standard:
- External links in formulas: Stored inside
<f>elements withinxl/worksheets/sheet*.xml. A formula referencing another workbook encloses the file path and sheet name in square brackets, such as='C:\Reports\[Q1.xlsx]Sheet1'!$A$1. These are cell-level references with no associated query logic or authentication mechanism. - Data connections: Defined in
xl/connections.xml. Each<connection>element can describe an ODBC, OLEDB, or web query source, including connection strings, command text, and refresh settings. These operate independently of any single formula and can pull entire tables into the workbook.
A workbook can contain one type without the other. Auditing requires checking both.
Locating External Workbook Links Through the ZIP Structure
Excel’s Data > Edit Links dialog displays only links the application can resolve or that are recorded in the workbook’s external reference part (xl/externalLinks/). Links embedded directly in defined names, chart series, or conditional formatting rules may not appear. For a complete inventory, inspect the raw XML.
Method 1: Search formulas across all sheet XML files
- Rename the
.xlsxfile extension to.zipand extract the contents. - Open a terminal in the extracted directory.
- Run a recursive grep for the opening bracket that signals an external reference:
This returns everygrep -r '\[' xl/worksheets/<f>element containing a bracketed path. Each result includes the sheet file and the formula text.
Method 2: Check defined names and other parts
External references also appear in:
- xl/workbook.xml (defined names scoped to the workbook)
- xl/worksheets/sheet*.xml (sheet-local defined names inside <definedName> elements)
- xl/charts/chart*.xml (chart data references)
- xl/pivotTables/pivotTable*.xml (pivot cache source references)
Grep the entire xl/ directory:
grep -r '\[' xl/
Method 3: Search within the application (limited)
- In Excel,
Ctrl+Hwith Look in: Formulas and search for[across all sheets. This catches formula cells but misses defined names, chart references, and conditional formatting rules. - In LibreOffice Calc, Edit > Find & Replace with Search in: Formulas and the regular expression
\[.*\]locates bracketed external paths in cell formulas only.
Limitation: Application-level searches do not inspect XML parts that lack a direct UI representation. The ZIP method is the only way to guarantee completeness.
Finding Data Connections and Query Definitions
Data connections do not appear in cell formulas. They are stored in xl/connections.xml and referenced by pivot tables, query tables, and other objects.
Inspection through the application
- Excel: Data > Queries & Connections lists every query with its source type and last refresh timestamp. Data > Connections > Workbook Connections shows a simpler list without query details.
- LibreOffice Calc: Data > Define Database Range displays ranges linked to external data sources. This does not expose the underlying connection string.
Direct XML inspection
- Extract the
.xlsxarchive. - Open
xl/connections.xml. Each<connection>element contains:nameandidattributes- A
typeattribute (e.g.,ODBC,OLEDB,WEB) - A
<dbPr>element with aconnection=attribute holding the full connection string - Optionally, a
<webPr>element with the source URL for web queries
- Cross-reference the connection
idwithxl/pivotTables/pivotTable*.xmlandxl/queryTables/queryTable*.xmlto identify which objects depend on each connection.
Common failure mode: A connection configured for a corporate ODBC driver (e.g., Driver={SQL Server};Server=internal-db;) will fail silently on a machine without that driver. The workbook opens without error, but Refresh All produces no visible change because the query cannot execute.
Checking for Stored Credentials Before Distribution
Some connection strings embed authentication details. Open xl/connections.xml and search for:
- password=
- uid=
- Integrated Security=SSPI (indicates Windows authentication; may succeed on a recipient’s machine if they are on the same domain)
If the connection string contains a plaintext password, the connection must be removed or the password stripped before sending the file. Deleting only the connection definition while leaving the last-imported data in the sheet preserves the visible values without the security risk.
Updating or Removing External Dependencies
The appropriate action depends on whether the source remains accessible and whether the workbook will be shared.
| Condition | Action | Consequence |
|---|---|---|
| Source file exists at a new path | Update the link path | Formulas recalculate from the new source |
| Source file is permanently unavailable | Break the link | Formulas replaced with last cached values; no further refresh possible |
| Workbook will be sent externally | Remove all links and connections | Prevents path disclosure and failed refresh attempts |
| Data connection is obsolete but data must remain | Delete the connection, keep the imported range | Static data preserved; query definition removed |
Updating a link path
- Excel: Data > Edit Links > Change Source, select the new file. All formulas referencing the old path update to the new one.
- ZIP method: Edit
xl/externalLinks/externalLink*.xmlto change thetargetattribute. This is error-prone; re-saving from Excel is safer.
Breaking a link
- Excel: Data > Edit Links > Break Link. Every formula pointing to that source converts to its last calculated value. Verify the cached value is current before breaking. Excel provides no warning if the cached value is months old.
Removing a data connection
- Excel: Data > Queries & Connections, right-click the connection, select Delete. The imported data remains in the worksheet as static values.
- ZIP method: Delete
xl/connections.xmland remove all<connection>elements fromxl/workbook.xml. Also remove any<queryTable>or<pivotTableDefinition>elements that reference the deleted connection IDs. Risk: If a pivot table retains a reference to a removed connection, Excel may refuse to open the file or display repair errors.
What Export and Conversion Strips Away
Converting an XLSX to CSV, HTML, or PDF removes all external dependencies irreversibly: - CSV stores only the displayed cell values. No formulas, no connection definitions, no pivot caches survive. - HTML may render the cached values but discards all formula logic and query metadata. - ODS (OpenDocument Spreadsheet) supports external references natively and can preserve link structures during conversion, though some connection types may not map cleanly.
If you need to retain the link structure for later reactivation, keep the file in XLSX format and break links only when you are certain the cached data is final.
Privacy Risks from Paths and Server Names
External references expose internal infrastructure details to anyone who inspects the file:
- A formula containing \\finance-server\budget\FY2025.xlsx reveals a server hostname and share name.
- A connection string with Data Source=db.internal.example.com discloses an internal domain.
- Web query URLs may include API keys or internal endpoints.
These strings persist in the XML even if the link is broken through the Excel UI. Breaking a link replaces the formula with a static value but does not remove the entry from xl/externalLinks/. To eliminate path disclosure entirely, delete the xl/externalLinks/ directory and remove all <externalReference> elements from xl/workbook.xml after breaking all links.
Audit Sequence
- Open the workbook and record any security warning messages.
- Extract the ZIP and grep
xl/for\[to find all formula-based external references. - Open
xl/connections.xmland inspect each<connection>element for type, source, and credential attributes. - Open
xl/workbook.xmland check for<definedName>elements containing bracketed paths. - For each dependency, decide: update the path, break the link and verify cached values, or delete the connection.
- If removing connections, delete or sanitize
xl/connections.xmland update all referencing parts. - Save the cleaned workbook under a new filename and confirm it opens without warnings.
The schema for connections.xml is documented in the Microsoft Open Specifications under Part 1, Section 15.2.