Questions tagged [xlwings]
Xlwings is a module to allow Excel to be automated with Python instead of VBA.
1,081
questions
0
votes
0
answers
25
views
Solution to an excel/python flask web server with xlwings
I have a complicated excel file that is a custom calculator with many formulas and macros. We input width, length, and a few other choices and get the feasibility checks, springs and tubes for the ...
0
votes
1
answer
49
views
How to get values of filtered excel data using Python?
I’m trying to get the value of each cell in every shown row after applying an AutoFilter to some columns.
Example code:
import xlwings as xl
filename = “C:\somepath\Data.xlsx”
# Example of Excel data ...
0
votes
1
answer
34
views
Insert data in the next row per loop in excel file using python xlwings
I want to automate our current process of comparing data.
Basically I want to save the data per loop and every loop it will insert the data to another row.
as of now what happening is it will just ...
0
votes
0
answers
29
views
xlwings VBA RunPython is failing to generate logfile
I am trying to get a VBA macro to call a python program (using xlwings), which will create a logfile as it runs, among its other objectives.
I have the following python function (It creates a basic ...
1
vote
2
answers
68
views
Adding more than one empty row between pandas groups without append
I want to add several empty rows between each groupby in my pandas dataframe. I know similar questions have been asked in the past but all of the answers I could find rely on the recently discontinued ...
0
votes
1
answer
59
views
Display dataframe as a handle on Excel via XLwings
I am trying to write a function to return dataframe by handle via Xlwings:
@xw.func
@xw.ret(index=False)
def create_df():
# initialize data of lists.
data = {'Name': ['Tom', 'nick', 'krish', '...
0
votes
1
answer
62
views
How to create a combo / combination chart in xlwings?
I'm trying to create a combo chart in excel through xlwings and I'm not able to do it. In the documentation it says you can set the chart_type to 'combination' but when running the code:
wb = xw.Book()...
0
votes
1
answer
60
views
Autofill the Formula to the last occupied cell in a range xlwings
I want to drag the formula to the last occupied range of cell like excel.
I have added formula using copy paste from range CN6:CY6 to CN8:CY8 with cell referencing but now i want to drag/autofill the ...
1
vote
2
answers
49
views
Delete entire row if all cells are empty in range of cells using Xlwings
I have many ways but i'm struggling to improve the performance of this code. Any alternative please do suggest.
I am trying to build a code to delete the entire row if all cell are empty in a range, i ...
1
vote
1
answer
41
views
Assign axes to the chart in xlwings
By using the script below I can generate the chart but it assigns columns to abscissa. How can I assign the rows to it, i.e. x,y,z as abscissa and A,B,C as ordinates.
import xlwings as xw
wb = xw....
0
votes
1
answer
58
views
xlwings: fill the combobox of a user form from a panda dataframe
I have a pandas dataframe containing the records of an SQL query.
I would like to use xlwings to insert the data of this dataframe into the combobox of a user form.
I have something like that:
cb = xw....
0
votes
0
answers
36
views
Python pypyodbc cursor (data) to excel sheet
I have obtained a cursor (data recordset) from sql server using pypyodbc. I have xlwings library and have spawned a workbook. I can simply loop through each row of the cursor and write the fields of ...
0
votes
1
answer
27
views
Both sqlite not in and not exists clause are not returning any data when I use different column names as criteria
I'm using the XLWINGS add-on for Excel in order to use SQL directly inside of Excel. (XLWINGS is a Python add-on that uses SQLite for queries.)
I'm analyzing a table of approximately 20,000 records ...
0
votes
1
answer
34
views
How to parse a date as an argument in xlwings
I would like to parse a date as an argument in a python function but it is not recognized.
For example:
def myfunction(cob_ToGet):
# cob_ToGet is datetime
print(cob_ToGet.strftime("%d.%m.%...
0
votes
1
answer
70
views
Python&Excel: Issue when trying to run a macro / refresh pivots
I am generating an Excel with Knime and afterwards I am using python to make some adjustments to the file.
I am taking the data from the output of Knime and pasting them into a pre-formatted Template....
1
vote
1
answer
43
views
Using Excel Add-in xlwings gives end of file error
I have installed xlwings in anaconda's base environment and installed the excel add-in as well. I have been able to import User-Defined Functions. However, recently, it has started to bug out. ...
0
votes
0
answers
54
views
Task scheduler not executing Python containing Xlwings library
I have a Python script which I uploaded into task scheduler but it returns 0x1 error. The script is running well in cmd/visual studio code.
I have tried the following steps but it does not work.
...
1
vote
1
answer
44
views
How to webscrape multiple tables on same website
I am trying to webscrape multiple tables from this website
this is my code
def scrape_ranking(url, sheet_name):
with sync_playwright() as pw:
browser = pw.chromium.launch()
page = ...
0
votes
0
answers
30
views
Trying to delete rows by including a variable in the Range object using xlwings
Not entirely sure why this does not work.
for x in ws.range('E2','E'f'{last_row}'):
if x.value != "CAD":
del_row = x.row
xw.Range(del_row,del_row).api....
0
votes
1
answer
39
views
Hide Excel's Pivot Table Field List
I have an excel file and created a pivot table in the same using win32com.client library but when opening this excel file it has the PiVotTable Fields tab in the sheet below :
Manually it can closed ...
0
votes
0
answers
24
views
Workaround for xlwings UDFs in Excel with cl commands blocked?
I have been attempting to import UDFs into an Excel workbook using xlwings (using the simple UDF given in the xlwings docs https://docs.xlwings.org/en/latest/udfs.html#udfs). This process is being ...
0
votes
0
answers
41
views
Problems with xlwings sheet.range(a,b)value
Can someone help me with this?
import xlwings as xw
workbook = xw.Book(workbook)
sheet = workbook.sheets[sheet]
value = sheet.range(8, 14).value
I have checked that workbook and sheet were properly ...
0
votes
1
answer
126
views
Delete all comments in an excel-sheet using xlwings python on MacOS?
I am looking for a method to delete all comments in an Excel-sheet using python.
On Windows i can do this using the following command:
ws2.used_range.api.ClearComments()
But this is not working on ...
0
votes
1
answer
48
views
TypeError when writing large dataset to Excel using Python xlwings
I have two dataframes (df1 and df2). df1 is imported from a csv and is about 500 records and I can use the .tables['table_name'].update() method perfectly fine.
df2 is a concatenation data imported ...
1
vote
0
answers
23
views
troubleshooting visible issues in xlwings
I made Excel automation using xlwings.
Even if I use xw.App (visible=False), if I use Excel for other tasks locally, I've noticed that the Excel window I'm working on in automation keeps turning on ...
0
votes
1
answer
57
views
xlwings: terminate VBA execution upon Python error
I have an Excel VBA subroutine that calls a Python function with the xlwings RunPython command. If the called Python function terminates due to an error, then a pop-up with the Python error traceback ...
1
vote
0
answers
70
views
pywin32 is installed but the dependency package could not found it
OS:windows
ERROR info:
xlwings.XlwingsError: Make sure to have "pywin32", a dependency of xlwings, installed.
I am using a company computer. Due to some restrictions, I installed Python by ...
0
votes
0
answers
45
views
append dataframe to an existing excel file with keeping a vba
import xlwings as xw
file_path = './DD_Template.xlsx'
sheet_name = 'Citation'
start_row = 2
wb = xw.Book(file_path)
sheet = wb.sheets[sheet_name]
writer = pd.ExcelWriter(file_path, engine='...
0
votes
0
answers
31
views
List From Dynamic Row & Column (2 dimentional)- Xlwings
import xlwings as xw
wb = xw.Book("adsd.xlsx")
sht = wb.sheets["test"]
lrow = sht.range('A7').end('down')
lcol = sht.range('zz7').end('left')
a = A7:Z70 list
Is that possible to ...
0
votes
0
answers
81
views
xlwings pywin error (-2147023170) 'the remote procedure call failed.' and killing the app
I am running a code to create graphs on excel as chartsheets (lets say 100) with 4 to 10 series on each.
The line is this:
chart = data_sheet.charts.add()
Which yields:
ret = self._oleobj_....
1
vote
1
answer
82
views
Python: xlwings and sub directories
I have 2 functions. I want to check if a file exist in a sub directory.
def XlCall():
wb = xw.Book.caller()
from pathlib import Path
entries = Path('./History/data.csv')
wb.sheets('TA')...
0
votes
1
answer
79
views
Marking down excel columns by the header names in xlwings/pandas
Is there a way I can mark down the Excel columns by the header names in any python webscraping tool?
For example, column A is snacks, B is drinks, and C is fruits:
In python, if I wanted to add ...
0
votes
0
answers
82
views
Opening two workbooks with Xlwings in same app instance, making one visible and one not
I am making a program using Xlwings and Python, which allows a user to enter information on one excel workbook, and outputs data based on calculations which reference another workbook.
I am trying to ...
0
votes
0
answers
42
views
How can I revert xlwings automatic conversion from date format to number format?
I have a Dataframe with Date column that I want to transfer to Excel using Xlwings, maintaining the Date format. Xlwings automatically converts dates to numbers. To avoid this the dates were converted ...
0
votes
1
answer
62
views
Is there any way to keep conditional formatting after clearing content in excel sheet when using xlwings?
I have written a piece of code that clears all data from a sheet in an excel macro-enabled workbook and loads a data frame. After a lot of digging, I found out that the best library is Xlwings. ...
0
votes
0
answers
268
views
I cannot determine why I am getting the Syntax Error "unterminated string literal" in Python called from Excel VBA via xlwings
I am very inexperienced Python user and only beginning to learn the language. After checking multiple possibilities I still cannot determine why I am getting this error and how to fix it?
The python ...
1
vote
1
answer
69
views
Why does excel add an '@' in the middle of my formula?
This is a small part of my web scraping code.
wb = xw.Book("jockeyclub.xlsx")
rc1 = wb.sheets['Race Card 1']
besttime = 7
rc1.range('S7').formula = f'=MIN(IF({besttime}1:{besttime}150<&...
0
votes
0
answers
113
views
How to make xlwing wait untill saving is completed to close the file
I have been using xlwings to edit some excel files in python, but i am having trouble for one specific file. After I am done editing it, I pass a command for python to save and close that workbook, ...
1
vote
0
answers
152
views
Python script using xlwings fails to open Excel workbook when run from Windows Task Scheduler
Windows 10
xlwings 0.30.8,
Microsoft Excel for Microsoft 365 MSO (ver 2302 16.0.16130.20586) 32 bit,
Python 3.9.12
Describe your issue (incl. Traceback!)
I am experiencing a problem with my Python ...
0
votes
0
answers
36
views
Xlwings is moving the cell value up itself
When I re-run the calculations in Excel or Python. The value in a specific cell moves up itself. I didn't program that.
What may be the issue?
sheet.range("B23").value = ["Metal walls (...
0
votes
1
answer
89
views
Xlwings 'pictures.add()' returns error "got an unexpected keyword argument 'anchor'"
I tried to use python's xlwings module yesterday to add some pictures to Excel, however the code returns an error.
The error states that ws.pictures.add() does not have the parameter called "...
0
votes
0
answers
58
views
How do you set the timeout for macros with xlwings?
I have macros that can take up to 2 minutes but i keep hitting the OS automation timeout and it doesn't appear that setting the timeout via 'properties' method is having any effect. Anyone know if ...
-1
votes
1
answer
124
views
Loop over rows in worksheet and merge cells in Python [duplicate]
I would like to loop over my DataFrame worksheet and merge the cells in every 2 rows within one column. For example my DataFrame looks like this:
However, the end goal is for it to look like this:
I ...
1
vote
1
answer
82
views
Write comment to excel-cell and autofit the comment-box?
i was able to add a comment to an excel-cell using the following code:
import xlwings as xw
wb = xw.Book("test.xlsx")
ws = wb.sheets[0]
ws.range("A1").api.AddComment(Text="My ...
0
votes
0
answers
74
views
Speeding yfinance functions in Excel
I am trying to speed up the results from a UDF called in Excel. The formula simply reads the current stock price. The formula below works fin, but when you copy it to over 100 stock symbols, it takes ...
1
vote
0
answers
46
views
Copy value of Pandas dataframe without conversion type using xlwings [closed]
i have a problem while writing a pandas Dataframe into excel file using xlwings: i have a pandas dataframe that contains strings like '001' or '001234' but also numerical values as 3477 and when i use ...
-1
votes
1
answer
70
views
I want data from DDE to pandas dataframe without using excel, i am getting data like below
Symbol Name XCH LTP Qty. Chg % Chg Bid Qty Bid Ask Ask Qty Total Bid Total Ask Open P.Close Low High T.Volume Strike Price Exp. Date <br>
NIFTY23JUN18500CE NSE
=DARTSCRDE|...
0
votes
1
answer
85
views
Adding Xlwings autofilter returns an error
Hello I have a problem when I add filtering code below
Everything is okay before adding the filter code
# 필터를 적용할 시트 선택
sheet = inventory_workbook.sheets['Raw data']
# 필터를 적용할 열 범위 선택
column_range = ...
0
votes
0
answers
47
views
xlwings standalone addin missing function ConvertToUTC
I have created an Excel file and .py file using
xlwings quickstart hello --standalone which works fine. But when I run the macro that should print "hello" in A1, I get an error saying "...
0
votes
2
answers
115
views
Issue with Special Characters in xlwings when importing VBA Modules in VS Code
I am currently encountering an issue with the xlwings package while working on a project in Excel.
When I use the command xlwings vba edit to import VBA Modules into Visual Studio Code, all special ...