How do I save a workbook using xlwings?

I have an excel worksheet, some buttons and some macros. I use xlwings to make it work. Is there a way to save the workbook through xlwings ? I want to extract a specific sheet after doing an...

xlwings: can I make a live link to an already open workbook?

I am trying to use xlwings to link Python to Excel. With good success, but I can not link to an already opened (and modified) excel workbook. So the workbook is already open in Excel, I want to...

From pandas to excel via xlwings - do not deposit index

Range("A1").value = p.df_sector[["A","B","C"]].sort(columns=["C"],ascending=False).head(4) Works wonderfully! But - I do not want/need to see the index...

xlwings: set foreground text color from Python

I'm using xlwings on a Mac and would like to set the foreground color of text in a cell from Python. I see that range.color will change background color which I could use but it has an additional...

How to Pass Arguments from xlwings to VBA Excel Macro?

I was looking at https://stackoverflow.com/questions/30308455/how-do-i-call-an-excel-macro-from-python-using-xlwings, and I understand it's not fully supported, but I Would like to know if there...

pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147352565), None)

I was created example from http://docs.xlwings.org/en/stable/vba.html /Python 3.5.1 |Anaconda 2.5.0 (32-bit)| (default, Jan 29 2016, 15:46:01)/ and got...

How can I read every field as string in xlwings?

I have an exelfile that I want to convert but the default type for numbers is float. How can I change it so xlwings explicitly uses strings and not numbers? This is how I read the value of a...

xlwings:copy a worksheet, and reproduce it at the end of an existing worksheet

I'm useing xlwings on a Windows. I copy a worksheet and want to reproduce it at the end of an existing worksheet now. In a worksheet to copy, I use a photograph and the figure. I know some sample...

Open a Workbook with XLWINGS without making it visible

I am starting to use XLWings (not that I like Excel, at all, but it is something I HAVE TO do). The thing is that I cannot find the way to make Python open a Workbook without showing it. It seems...

one hot encoding for frequent values only

I am looking to do one hot encoding to a column, but only for those that are very frequent. All that are below a threshold T will be put in their own category. My strategy was to create a...

xlwings: Delete a col | row from Excel

How do I delete a row in Excel? wb = xw.Book('Shipment.xlsx') wb.sheets['Page1_1'].range('1:1').clear() .clear() works to remove the content. I want to delete the row. I'm surprise the .clear()...

xlwings: make cell bold

I have seen that stylistic requests are to be implemented in xlwings. Is there a workaround to make the content of a cell bold?

Distribute xlwings macro without xlwings installation?

I'm having trouble finding an answer to this - I'm writing some simple VBA with the goal that my colleagues can install it as an add in or custom tab. Coming from Python I would, of course, prefer...

Copying a worksheet with xlwings and python

I have been using xlwings in Python, but have not been able to figure out how to copy a worksheet. I want to treat a particular worksheet as a template, and copy that worksheet each time before...

How do I delete a row in Excel with xlwings?

I know this was answered before (xlwings - Delete a range of rows), but does not work any more.... I'm using python 2.7 with xlwings 0.11.7 edit:(on Mac) The answer from above mentioned...

Copy pasting multiple sheets into new workbook

The goal is to copy paste multiple existing sheets out of a workbook into a new workbook using xlwings. I have: app = xw.App(visible=False) book = xw.Book(path) sheet_1 =...

Python: why do I get an error when I import geopandas?

I try to import geopandas in my jupyter notebook. import geopandas as gp and I get the following error: ImportError:...

WEBP support not installed error with Pillow included in Anaconda

I have written a small code to open webp image in the Anaconda prompt. from PIL import Image im = Image.open('test.webp') It causes the following...

Copy excel sheet from one worksheet to another in Python

All I want to do is copy a worksheet from an excel workbook to another excel workbook in Python. I want to maintain all formatting (coloured cells, tables etc.) I have a number of excel files and...

"AssertionError: Torch not compiled with CUDA enabled" in spite upgrading to CUDA version

I figured out this is a popular question, but still I couldn't find a solution for that. I'm trying to run a simple repo Here which uses PyTorch. Although I just upgraded my Pytorch to the latest...

Read Excel sheet table (Listobject) into python with pandas

There are multiple ways to read excel data into python. Pandas provides aslo an API for writing and reading import pandas as pd from pandas import ExcelWriter from pandas import ExcelFile df =...

How to ensure xlwings connection is closed if script fails

I am trying to develop something with xlwings because I need to manipulate a xls file with macros etc. Although it is always good to close connections, Excel is notorious in that it blocks access...

How to skip default index (series column on the left) when writing data from dataframe in pandas into Excel through xlwings?

item sales 0 A 100 1 B 200 2 C 300 3 D 230 4 E 470 5 F 168 I have a dataset like above in pandas dataframe, and I wrote those data into an Excel file using...

Retrieving full rich-text data from a cell (multiple font color / styles within cell)

openpyxl can only read and write one font color per cell xlwriter supports multiple font colors but only serves for writing and not reading. xlwt is only for writing too. xlwings doesn't support...

Move worksheet within a workbook to the end

With xlwings, I am trying to move a worksheet within a workbook to the end. For example, a workbook contains a collection of the following sheets: Sheet1, Sheet2, Sheet3 How can I move Sheet1...

Plotly: How to add multiple y-axes?

I have data with 5 different columns and their value varies from each other. Actual gen Storage Solar Gen Total Gen Frequency 1464 1838 1804 18266 51 2330 2262 518 4900 ...

Excel.exe process keeps on running if visible false after any error

Usually I use the following code to open an excel workbook in the background: import xlwings as xw app = xw.App(visible=False) wb = xw.Book(filename) sheet = wb.sheets['sheet1'] I sometimes do...

From pandas dataframe to excel with xlwings?

I have a pandas dataframe where I did a 24x 12 matrix with colors to be able to represent my data better. What I want to do is put this in excel with xlwings. But I don't know how. I have already...

How can I create an image from a STEP file in python

I currently have a python script using the freecad API to read a step file and send some data to an excel file (volume, dimensions, etc.) with xlwings. I would like to also add a view of the STEP...

xlwings keyerror when running macro from excel

I am following the xlwings tutorial. I downloaded and the xlwings plugin, and used the command xlwings quickstart heart Which created a folder with two files, heart.xlsm and heart.py. I then...