Fix Slow Python and xlwings Data Exports to Excel
Question details
The user is experiencing slow export speeds when sending large amounts of data from Python to Excel using xlwings, and wants to know if multithreading can be used to parallelize the process.
- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Exporting large datasets or streaming high-frequency data from a Python script into an active Excel worksheet.
- Observed behavior
- Excel worksheet writing cannot easily be parallelized, making direct COM-based data transfers slow and prone to bottlenecking.
Before modifying your Python scripts or Excel setup, check if your workflow permits saving intermediate data to plain text files (like CSV), as bypassing direct COM interaction is the most effective way to improve performance.
Use CSV Intermediaries with Excel VBA Automation
Bypass Excel's single-threaded COM limits by having Python write data to a CSV file, and using an Excel macro to automatically import and clean up the files.
Excel does not natively support multithreaded writing from external applications. Writing data continuously via xlwings can cause the application to freeze.
Instead of forcing direct connections, you can decouple the process. Let Python write the data quickly to disk, and have Excel poll the disk for new data.
Adjust your Python code to write the data output to a designated local CSV file instead of sending it directly through xlwings.
Open Excel, press Alt + F11 to open the VBA Editor, and write a macro that periodically checks a specific folder for the newly created CSV files using the Application.OnTime method.
Program the macro to open the CSV, copy the data into your main workbook, and then delete or move the CSV file so it is ready for the next batch.
Temporarily disable Application.Calculation and Application.ScreenUpdating at the start of your macro to prevent Excel from freezing while the new data is imported.
Batch Write Data to CSV Before Opening
If real-time updates are not strictly required, batch all data processing in Python first and open the final output file in Excel.
Try WPS Office for Fast Data Handling and Broad Compatibility
Handling large datasets and complex macros can bog down traditional spreadsheet software. WPS Office offers a lightweight, high-performance alternative that fully supports CSV importing and VBA macros, making it an excellent environment for automated data handling.
- 1. Download and Install WPS Office: Get the free WPS Office suite from the official website and install it on your device.
- 2. Open your CSV files instantly: Use WPS Spreadsheet to natively open and handle large CSV outputs generated by your Python scripts without performance hiccups.
- 3. Run your macros: Utilize the built-in Macro capabilities in WPS Spreadsheet to automate repetitive importing tasks just as you would in Excel.

Frequently Asked Questions
Why is xlwings slow when exporting large datasets to Excel?
xlwings uses the Component Object Model (COM) to interact with Excel. Passing data back and forth between the Python process and the Excel process creates significant overhead. This makes cell-by-cell or row-by-row writing extremely slow.
Can I use multithreading to write to Excel from Python?
No. Excel's user interface and object model are strictly single-threaded. Attempting to write to a worksheet from multiple threads simultaneously will result in errors or cause the application to crash.
Is there a way to speed up xlwings without using CSVs?
If you must use xlwings, you can improve speed by minimizing cross-process calls. Format your data as a 2D list or a NumPy array in Python, and assign it to an Excel range in a single operation (e.g., sheet.range('A1').value = my_data_array).




