Utilities to solve macOS-specific issues with xlwings automation
Project description
xlwings-macos-utils
Workarounds for macOS-specific issues when automating Excel with xlwings.
The Problem
On macOS, xlwings users face two blocking issues:
- File Permission Dialog (Error -1743) - macOS shows a "Grant Access" dialog that freezes script execution
- External Links Update Prompt - Excel asks to update external links on every file open
These are well-documented issues: #1966, #2559, #1262
Installation
pip install xlwings-macos-utils
Requirements: macOS 10.14+, Microsoft Excel, Python 3.8+, xlwings 0.27.0+
Quick Start
import xlwings as xw
from xlwings_macos_utils import configure_excel_no_alerts, open_workbook_with_workaround
# Step 1: Configure Excel (call once at start)
configure_excel_no_alerts()
# Step 2: Create Excel app
app = xw.App(visible=False, add_book=False)
try:
# Step 3: Open workbook using the workaround
wb = open_workbook_with_workaround(app, '/path/to/file.xlsx')
if wb:
# Your automation code here
sheet = wb.sheets[0]
data = sheet.range('A1:C10').value
print(f"Read data from {wb.name}")
wb.close()
finally:
app.quit()
API
configure_excel_no_alerts()
Configures Excel via AppleScript to suppress alerts and external link prompts.
Important: Call once at the beginning of your script, before opening any files.
open_workbook_with_workaround(app_excel, file_path)
Opens an Excel workbook using AppleScript to bypass the permission dialog.
Parameters:
app_excel(xw.App): The xlwings Excel application instancefile_path(str): Absolute path to the Excel file
Returns: xw.Book if successful, None on failure
How It Works
Uses AppleScript to:
- Configure Excel settings (
set display alerts to false,set ask to update links to false) - Open files via
open POSIX file(non-blocking) - Connect via xlwings with automatic retry
Troubleshooting
| Problem | Solution |
|---|---|
| "Could not configure Excel alerts" | Ensure Excel is installed |
| "Failed to open via osascript" | Verify file path is correct and absolute |
| "Could not connect to workbook" | Check if Excel is responsive, try increasing retry delay |
| Still getting permission dialogs | Ensure configure_excel_no_alerts() is called first |
Contributing
git clone https://github.com/andreggalvao/xlwings-macos-utils.git
cd xlwings-macos-utils
pip install -e ".[dev]"
pytest
License
MIT - see LICENSE
Related Issues
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xlwings_macos_utils-0.1.0.tar.gz.
File metadata
- Download URL: xlwings_macos_utils-0.1.0.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16800b62c7caa4cfd15cc375805b12b1b17b3fea3dd2512ee1a36a5fbf90c63d
|
|
| MD5 |
4c3d8b470be4d7fdf9ec83b0327ee38c
|
|
| BLAKE2b-256 |
aa35900b67d697c853b283337792d5018f8393591f7edbb7844864d4d99680d8
|
File details
Details for the file xlwings_macos_utils-0.1.0-py3-none-any.whl.
File metadata
- Download URL: xlwings_macos_utils-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4b081656a4f309fef8b38f13b74d692ffcd21d7e597cd49c65c6ae305e79729
|
|
| MD5 |
498c4aa6a66d8454b74dc787c15f8ead
|
|
| BLAKE2b-256 |
feca5bcb838f3d4fef67f6974bc653f319d13cfb0f075664998af858ead2cfa2
|