1,134 questions
4
votes
0
answers
142
views
How to read mixed data (numbers and strings) from Excel with xlwings without converting 123 → 123.0
I’m using xlwings to read an Excel sheet into a pandas DataFrame with the built-in pd.DataFrame converter.
Some of my columns contain mixed data (e.g. IDs or codes like 123, 00123, ABCD).
When I read ...
0
votes
0
answers
100
views
Why xlwings custom scripts fails with queries and connections in excel file?
I use xlwings server, installed it as described here: , it runs on one of the VMs of my server. On another VM (Win Server 2025) I installed python, xlwings, xlwing addin and other dependencies. In the ...
0
votes
0
answers
94
views
How to automatically trigger Ctrl+Shift+Enter for array formulas in Excel after adding sheets with Python?
I have a main Excel workbook containing array formulas, which reference data from several sub-workbooks (or sheets). The workflow is as follows:
The main workbook initially does not contain the sub-...
1
vote
1
answer
90
views
How to Bypass "Grant Access" when using Xlwings
I am in the process of porting over some python excel automation scripts to work on MacOS (previously they were run on windows, and used the pywin32 library to "refresh" an excel file - the ...
0
votes
2
answers
97
views
Try to open Excel.xlsm file using xlwings results in Com-Error
I'm currently working on a project where I need to open an .xlsm Excel file through my code.
However, I keep running into the following error:
öffnen
Traceback (most recent call last):
File "C:\...
0
votes
1
answer
57
views
How to copy a picture cell using python with xlwings?
I try to copy the picture cells in column B using xlwings with the following code-snippet to first read all the images:
import os
import sys
import xlwings as xw
path = os.path.abspath(os.path....
1
vote
2
answers
146
views
Get the current folder of Excel from xlwings Lite addin
I am using xlwings Lite addin with Excel 2021. Is there any way to get the path of Excel file from xlwings Lite? I tried to use os.getcwd() function, but it returns python working directory.
Thanks,
0
votes
1
answer
63
views
UnboundLocalError when trying to access a sharepoint file using xw.Book
I am trying to access an excel which is stored in sharepoint. I am opening that particular file runs_excel after closing all excel instances from Task Manager. This used to work since the last six ...
0
votes
2
answers
234
views
How to force a string to stay a string and not be converted to a date ? - Python [closed]
I'm facing an issue while pushing data into Excel using Python.
I need to write a string like "4/10" to a cell, but Excel automatically converts it into a date.
However, "4/10" is ...
1
vote
1
answer
259
views
Reticulate with pywin32, a dependency of xlwings, not found when sourcing python script from R [duplicate]
Overview
I have a python script opens an excel workbook, makes some changes, then saves it. This is just one step in a series of excel processing operations, most of which are written in R. My end ...
0
votes
1
answer
93
views
pipx installed xlwings module not found
I have an Excel workbook that uses an xlwings RunPythonScript() call to an external python script. As I want to run this python script outside of my vdev I've installed pipx and through pipx installed ...
0
votes
0
answers
64
views
How to make xlwings work on mac Sonoma? Error message tells I need to have appscript and psutil dependencies
Trying to install xlwings on a mac. MacOS Sonoma, version 14.7.1. Python 3.12. Installed through Anaconda. I get the error message
XlwingsError: Make sure to have "appscript" and "...
0
votes
0
answers
75
views
python clearing Excel autofilter
I'm currently automating a process using python and xlwings and need to clear any AutoFilters in a target excel worksheet. I've seen numerous samples that refer to using
if wb.sheets[sheetname].api....
0
votes
0
answers
74
views
Using Python to Import data from MySql into Ms.Excel ListObject
I am trying to automate a process where we need to import data from MySQL Database in to a ListObject (Ms.Excel Table).
Environment:
Ms.Office Professional 2021
Windows 10 pro
Python 3.12.1
The code ...
0
votes
0
answers
19
views
Set Excel function "FILTER" with Xlwings and Python [duplicate]
Im am trying to set the "FILTER" function in Excel with Xlwings. Below is my Code:
wb = xw.Book('table.xlsx')
wb.app.visible = False
sheet = wb.sheets['Sheet1']
formula="""=...
0
votes
0
answers
145
views
When running xlwings from VBA, I'm getting an "invalid procedure call or argument error". Why, and how do I fix it?
I'm trying to run a simple python script from VBA using xlwings, but I am getting an error "Run time error '5': Invalid procedure call or argument".
I suspect that this is because it is ...
2
votes
2
answers
196
views
Using xlwings, is there a way to collapse all the groups on a sheet?
I'm using xlwings with python to copy one excel sheet to another. As part of the copying, however, I'd like to collapse all the grouped columns.
This is different than hiding the relevant columns and ...
-1
votes
1
answer
144
views
Why can't my Mac's Terminal find the xlwings command?
I installed xlwings with pip3. It says:
% pip3 install xlwings
Requirement already satisfied: xlwings in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (0.33.4)
...
0
votes
0
answers
85
views
FreezePanse generates Unable to set the FreezePanes property of the Window class during visible = False
I am trying to set FreezePanes on the first column in my Sheet using xlwings. As suggested by @Felix Zumstein in the thread below:
How to freeze pane in XLWings
app: xw.App = xw.App(visible=True)
wb: ...
0
votes
1
answer
116
views
Dynamically fill the entry in tkinter and xlwings
I have an entry widget in my GUI to be dynamically filled with the cell range based on the cells have selected in the spreadsheet.
For example, if I selected A1:F30 in a sheet, it will put the range ...
0
votes
0
answers
54
views
Applescript reporting syntax error. Automation script for excel using python, xlwings, VBA and applescript on macOS
The code aims to open an Excel spreadsheet, add VBA code (to create some buttons) and close the spreadsheet.
import subprocess
# This function is called at the end of another python file (everything ...
1
vote
0
answers
69
views
Xlwings Converting a Cell to an Excel DataType (e.g., Stocks, Currencies)
I'm trying to setup a command using Xlwings within a Python script to set a specific cell within an Excel worksheet to an Excel Data type (e.g., Stocks, Currencies). I've found the VBA code that sets ...
0
votes
1
answer
90
views
How change columns color in chart under mathematical conditions Excel.Xlwing (by code, not FC in excel)s?
Is possible to change the color of a column under mathematical conditions in Excel-Xlwings, by code (not FC in excel). I mean, with the table:
Name
vote
Rossi
5
Bianchi
7
Verdi
8
Neri
4
I would like ...
1
vote
1
answer
48
views
xlwings python fails to read excel data
I am trying this code because it can read the data with an open excel workbook.
import xlwings as xw
xlsfile = r'C:\Users\matth\OneDrive\Dokumente\20241023-1904097928-umsatz.xlsx'
workbook = xw.Book(...
0
votes
1
answer
281
views
Create a Pivot Table Using xlwings
I am trying to automatize the creation of pivot table using xlwings. Here is a random piece of code I created which is supposed to create a pivot table, but I am getting an error at the line where ...
0
votes
2
answers
194
views
How do I programmatically (via Python/xlWings) add axes to an existing chart?
I have a very odd problem.
I have a python script that adds data every week to an existing Excel spreadsheet to track a weekly metric I'm interested in. When it pastes the new data in the existing ...
0
votes
0
answers
43
views
Pasting Value to First Available Cell in a Specific Column (Last Row + 1)
I'm having difficulty in pasting a value to the "next row". Essentially, a line in the code clicks a location in an application, copying a value to the clipboard. I then want to paste that ...
0
votes
1
answer
283
views
Apply different color coding within a cell with OpenPyxl
I have several already made excels that I'd like to format.
One of these formatting is to set a part of a cell in green, and the other part in red.
For the sake of this example, let's imagine cell &...
2
votes
2
answers
198
views
Preventing date conversion in Excel with xlwings
the problem is as the title states. I have a column AX filled with values. The name of the column is "Remarks" and it will contain remarks but some of those remarks are dates and some are ...
0
votes
1
answer
84
views
Is there a way for python to update an excel slicer in non-interactive mode?
I have a python script that refreshes data connections, updates slicers and filters.
I'm using pywin32 to update my excel file. As I understand, updating excel slicers and filters requires COM ...
0
votes
1
answer
114
views
Replaceformat with xlwings
does xlwings support replace_format?
I have a large array 200 rows and 250 columns and if I try to color each cell that has a value of “car” to red, it will take so much time to loop through each cell ...
0
votes
1
answer
137
views
Unable to set AutoFilter in .xlsx spreadsheet using xlwings
Using xlwings I'm trying to set an Autofilter on column E of a spreadsheet looking for text "DJM". My code just hangs at the AutoFilter line and does not do anything.
The code snippet is ...
1
vote
1
answer
260
views
Exception thrown in Visual Studio when trying to use xlwings in python to run a basic subroutine in an excel VBA module
I'm trying to use Microsoft Visual Studio to run python code that uses the xlwings library to open a macro-enabled Excel workbook and run a VBA subroutine called MySub() that lives in Module1. When I ...
0
votes
0
answers
77
views
Is xlwings in python able to pass =INDIRECT as a formula when using ws.range(cell).api.Validation.Add?
looking for some guidance. I'm trying to add validation to a range of cells in a .xlsm file. I want to dynamically add validation to some cells in column C, dependent on whether a value is present ...
0
votes
1
answer
266
views
Not able to open or call the current open file with xlwings
I'm not able to open or call the current active workbook using xlwings.
I'm on macOS Sonoma 14.5 and xlwings v0.31.10.
I keep getting this error (I'm running the .py file out of 4. Master):
...
0
votes
2
answers
133
views
Append rows to excel table using python, without clobbering formulas
so I am writing a script that grabs data from an excel sheet, processes it a bit, and then appends it to a different table on a different excel file. the target table has some pure data columns, and ...
0
votes
1
answer
139
views
XLWings data format as currency, not float
Using xlwings, I am connecting to Snowflake and extracting a Pandas dataframe. The dataframe is a mixture of text, dates, and floats, which I have verified by using df.to_excel. However, when I use ...
0
votes
1
answer
117
views
Using xlwings and macros in Personal.xlsb causes a "referenced by another workbook and cannot be closed" error when opening books
I usually don't ask questions and try to figure things out myself so apologies if the formatting or phrasing is poor.
I have a Python script which I want to call through a macro in excel using xlwings....
0
votes
1
answer
74
views
Can you use python xlwings library to trigger VBA code
I have a use case where I want to automate and interface an Excel model from The workflow would be something like:
Transfer data from Python to Excel
Execute macro to run model model to convergence ...
0
votes
1
answer
55
views
xlwings keep app open beyond lifetime of pytest script
I'd like to test an Excel file using xlwings and pytest. While writing tests, it would be helpful to have an option to keep the xlwings.App instance open with the test file, so that I can inspect what'...
0
votes
0
answers
87
views
I am trying to copy/paste a named Excel range to another range in the same worksheet using Python xlwings
I am trying to copy a named range in Excel (ex. "Question_1") and paste it into an empty area of the same worksheet, using Python (xlwings). I am getting an attribute error which mentions &...
0
votes
1
answer
132
views
How do I disable any kind of automatic conversion into excel when using xlwings?
When using xlwings, I want to, for example, write the string "4 / 5" into excel. However, if I write.
sheet[0,0].value = "4 / 5"
I get: string converted to date
I do not want to ...
1
vote
1
answer
180
views
Return multiple selected cells from excel into python via xlwings
I am trying to figure out how to pass several selected cells from excel into python via xlwings on macOS. I found code that passes cell notation but not all of the values.
For example: In my ...
0
votes
1
answer
167
views
Python xlwings slow Execution when scanning Excel Sheet
I'm a beginner at Python.
This code is for scanning Excel cells by range using xlwings however the process is very slow.
I strictly need to use xlwings since it can retain my images and shapes unlike ...
3
votes
1
answer
100
views
xlwings not updating global variable correctly when using threading
Here is my logic that I am trying to understand.
import xlwings as xw
import threading
workbook = ""
def function1():
t1 = threading.Thread(target=function2)
t1.start()
t1.join()...
0
votes
1
answer
86
views
Excel hangs in Python script to export excel as a pdf in Task Scheduler, but works normally
I'm trying to just automate creating a pdf from an excel file to email it out everyday. It should be simple, but it isn't. If I run these files in command line, they will run, create the pdf, and ...
0
votes
1
answer
71
views
matplotlib animation not working with xlwings
i am having issues with matplotlib animations when using xlwings, example from matplotlib:
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.animation as animation
import xlwings ...
1
vote
0
answers
77
views
Python XLSWINGS - Cannot access read-only document
I'm opening an Excel file for data entry using Python Pandas & Xlswings. Everything works fine as long as the Excel file is in an editable state (i.e. not opened by another user).
Firstly, has ...
1
vote
0
answers
67
views
Error using xlwings to create a worksheet in a new workbook
import xlwings as xw
wb = xw.Book()
sheet = wb.sheets.add('trade_summary')
Produces the following error message:
CommandError: Command failed:
OSERROR: -1728
MESSAGE: The object ...
0
votes
0
answers
45
views
How to read the font color of an excel-cell? [duplicate]
i have the folowing excel-sheet and try to read the font-color of the cell B3:
using the following code:
import openpyxl as ox
wb = ox.load_workbook("test.xlsx")
ws = wb.worksheets[0]
...