A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
To run SQL-like (DML) operations against an .xlsx Excel file on Windows, use an OLE DB connection string with the ACE provider and then execute SQL statements over that connection.
Example connection string for .xlsx (read/write DML):
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Path\To\YourFile.xlsx;Extended Properties="Excel 12.0 Xml;HDR=YES";
Explanation of key parts:
-
Provider=Microsoft.ACE.OLEDB.12.0;– Uses the ACE OLE DB provider for Excel. -
Data Source=...– Full path to the .xlsx file. -
Extended Properties="Excel 12.0 Xml;HDR=YES";-
Excel 12.0 Xml– Indicates an .xlsx-format workbook. -
HDR=YES– First row contains column names (useHDR=NOif the first row is data).
-
Once the connection is open, SQL statements can be executed such as:
SELECT * FROM [Sheet1$]
INSERT INTO [Sheet1$] ([Column1], [Column2]) VALUES ('Value1', 123)
UPDATE [Sheet1$] SET [Column2] = 456 WHERE [Column1] = 'Value1'
DELETE FROM [Sheet1$] WHERE [Column1] = 'Value1'
If the Excel column has mixed data types and values are being dropped or converted to NULL, add IMEX=1 to the extended properties to treat all data as text:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Path\To\YourFile.xlsx;Extended Properties="Excel 12.0 Xml;HDR=YES;IMEX=1";
How to install the Excel OLE DB driver (ACE) on Windows 11
To use the above connection string, the Microsoft Access Database Engine (ACE OLE DB provider) must be installed.
- Download and install Microsoft Access Database Engine 2010 Redistributable or a newer ACE redistributable (for example, 2016) appropriate for the system.
- Choose the correct bitness (32-bit or 64-bit) to match the application that will open the connection.
- After installation, the
Microsoft.ACE.OLEDB.12.0provider becomes available for use in connection strings like the ones above.
In Power Automate for desktop, the same provider is used with a variable for the file path, for example:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=%Excel_File_Path%;Extended Properties="Excel 12.0 Xml;HDR=YES";
This pattern applies equally when using other tools or custom code on Windows 11, as long as the ACE provider is installed.
References: